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 274301 f19f79a63cf2ba41229ffa0ff919085a05afd4ec
parent 274300 a808b9265d1792e4c282f576df0ce57214b51614
child 274302 39fdaf04c690f52d18607fbfefc302fa795aacbb
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [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) {