Curl_MD5_init: fix OOM memory leak

Bug: http://curl.haxx.se/mail/lib-2012-04/0246.html
Reported by: Michael Mueller
This commit is contained in:
Daniel Stenberg
2012-04-23 23:07:40 +02:00
parent dd18e714ff
commit bd9eb30ffd

View File

@@ -438,12 +438,14 @@ MD5_context * Curl_MD5_init(const MD5_params *md5params)
ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize); ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize);
if(!ctxt->md5_hashctx) if(!ctxt->md5_hashctx) {
return ctxt->md5_hashctx; free(ctxt);
return NULL;
}
ctxt->md5_hash = md5params; ctxt->md5_hash = md5params;
(*md5params->md5_init)(ctxt->md5_hashctx); md5params->md5_init(ctxt->md5_hashctx);
return ctxt; return ctxt;
} }