summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-07-24 20:55:38 +0000
committerphk <phk@FreeBSD.org>1996-07-24 20:55:38 +0000
commit8398830f31aa2e91c5f938cebe4205d9959dfb92 (patch)
tree604cf32c4bbdf15f5bf53133d9bb5c45487f4c35 /lib
parent9ca1f77c285387d6bcbe2eba1a888a95231f6569 (diff)
downloadFreeBSD-src-8398830f31aa2e91c5f938cebe4205d9959dfb92.zip
FreeBSD-src-8398830f31aa2e91c5f938cebe4205d9959dfb92.tar.gz
Fix a memory leak in MD[245]End()
Submitted by: Ikuo Nakagawa <ikuo@isl.intec.co.jp> PR: misc/1424
Diffstat (limited to 'lib')
-rw-r--r--lib/libmd/mdXhl.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index 817c551..ffab03a 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: mdXhl.c,v 1.5 1995/05/30 05:45:17 rgrimes Exp $
+ * $Id: mdXhl.c,v 1.6 1995/07/12 09:13:47 phk Exp $
*
*/
@@ -23,21 +23,20 @@ char *
MDXEnd(MDX_CTX *ctx, char *buf)
{
int i;
- char *p = malloc(33);
unsigned char digest[16];
static const char hex[]="0123456789abcdef";
- if (!p)
- p = malloc(33);
- if (!p)
+ if (!buf)
+ buf = malloc(33);
+ if (!buf)
return 0;
MDXFinal(digest,ctx);
for (i=0;i<16;i++) {
- p[i+i] = hex[digest[i] >> 4];
- p[i+i+1] = hex[digest[i] & 0x0f];
+ buf[i+i] = hex[digest[i] >> 4];
+ buf[i+i+1] = hex[digest[i] & 0x0f];
}
- p[i+i] = '\0';
- return p;
+ buf[i+i] = '\0';
+ return buf;
}
char *
OpenPOWER on IntegriCloud