Bug 1249641 - free dig if PK11_CreateDigestContext or PK11_CreateDigestContext fail. r?ekr
MozReview-Commit-ID: Hv5lr18YUyK
--- a/security/nss/lib/jar/jarsign.c
+++ b/security/nss/lib/jar/jarsign.c
@@ -46,20 +46,22 @@ JAR_calculate_digest(void *data, long le
if (dig == NULL) {
/* out of memory allocating digest */
return NULL;
}
md5 = PK11_CreateDigestContext(SEC_OID_MD5);
if (md5 == NULL) {
+ PORT_ZFree(dig, sizeof(JAR_Digest));
return NULL;
}
sha1 = PK11_CreateDigestContext(SEC_OID_SHA1);
if (sha1 == NULL) {
+ PORT_ZFree(dig, sizeof(JAR_Digest));
PK11_DestroyContext(md5, PR_TRUE);
return NULL;
}
if (length >= 0) {
PK11_DigestBegin (md5);
PK11_DigestBegin (sha1);