diff options
author | Daniel Stenberg <daniel@haxx.se> | 2012-04-23 23:07:40 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-04-23 23:07:40 +0200 |
commit | bd9eb30ffdde211574ba62b0ef5e1b75051fffda (patch) | |
tree | f46cf813992d06a6da689b3d855096ec91573fd8 | |
parent | dd18e714ff23d60ad43c524e290ab3e3093ba259 (diff) |
Curl_MD5_init: fix OOM memory leak
Bug: http://curl.haxx.se/mail/lib-2012-04/0246.html
Reported by: Michael Mueller
-rw-r--r-- | lib/md5.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -426,9 +426,9 @@ void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */ MD5_Final(outbuffer, &ctx); } -MD5_context * Curl_MD5_init(const MD5_params *md5params) +MD5_context *Curl_MD5_init(const MD5_params *md5params) { - MD5_context* ctxt; + MD5_context *ctxt; /* Create MD5 context */ ctxt = malloc(sizeof *ctxt); @@ -438,12 +438,14 @@ MD5_context * Curl_MD5_init(const MD5_params *md5params) ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize); - if(!ctxt->md5_hashctx) - return ctxt->md5_hashctx; + if(!ctxt->md5_hashctx) { + free(ctxt); + return NULL; + } ctxt->md5_hash = md5params; - (*md5params->md5_init)(ctxt->md5_hashctx); + md5params->md5_init(ctxt->md5_hashctx); return ctxt; } |