Bug 1161666 - |extract_signature| leaks memory if |sigIndex| > 0 (command line build utility). Free allocated memory while skipping signatures. r=rstrong
authorJosios <joseriosneto@gmail.com>
Thu, 07 May 2015 10:34:51 -0700
changeset 242936 f19f79a63cf2ba41229ffa0ff919085a05afd4ec
parent 242935 a808b9265d1792e4c282f576df0ce57214b51614
child 242937 39fdaf04c690f52d18607fbfefc302fa795aacbb
push id28714
push userkwierso@gmail.com
push dateFri, 08 May 2015 17:29:48 +0000
treeherdermozilla-central@5e8adf0e7f2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1161666
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1161666 - |extract_signature| leaks memory if |sigIndex| > 0 (command line build utility). Free allocated memory while skipping signatures. r=rstrong
modules/libmar/sign/mar_sign.c
--- a/modules/libmar/sign/mar_sign.c
+++ b/modules/libmar/sign/mar_sign.c
@@ -528,16 +528,19 @@ extract_signature(const char *src, uint3
   signatureCount = ntohl(signatureCount);
   if (sigIndex >= signatureCount) {
     fprintf(stderr, "ERROR: Signature index was out of range\n");
     goto failure;
   }
 
   /* Skip to the correct signature */
   for (i = 0; i <= sigIndex; i++) {
+    /* Avoid leaking while skipping signatures */
+    free(extractedSignature);
+
     /* skip past the signature algorithm ID */
     if (fseeko(fpSrc, sizeof(uint32_t), SEEK_CUR)) {
       fprintf(stderr, "ERROR: Could not seek past sig algorithm ID.\n");
       goto failure;
     }
 
     /* Get the signature length */
     if (fread(&signatureLen, sizeof(signatureLen), 1, fpSrc) != 1) {