Bug 1247217 - [CID 749520] Free pointers that should be freed. r=rstrong
authorPaul Bignier <paul.bignier@gmail.com>
Wed, 13 Apr 2016 22:58:11 -0700
changeset 293095 ea7e3da670d6a6bd3e358319133bbef0e2f24186
parent 293094 04f9767b4abe6e33d294b89ab29ae5c1b2b67484
child 293096 dbb14513cb83681e2c2832c712b95c23bc9bf468
push id18703
push userrstrong@mozilla.com
push dateThu, 14 Apr 2016 05:58:36 +0000
treeherderfx-team@ea7e3da670d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1247217, 749520
milestone48.0a1
Bug 1247217 - [CID 749520] Free pointers that should be freed. r=rstrong
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -3837,31 +3837,34 @@ GetManifestContents(const NS_tchar *mani
 
   size_t r = ms.st_size;
   char *rb = mbuf;
   while (r) {
     const size_t count = mmin(SSIZE_MAX, r);
     size_t c = fread(rb, 1, count, mfile);
     if (c != count) {
       LOG(("GetManifestContents: error reading manifest file: " LOG_S, manifest));
+      free(mbuf);
       return nullptr;
     }
 
     r -= c;
     rb += c;
   }
   mbuf[ms.st_size] = '\0';
   rb = mbuf;
 
 #ifndef XP_WIN
   return rb;
 #else
   NS_tchar *wrb = (NS_tchar *) malloc((ms.st_size + 1) * sizeof(NS_tchar));
-  if (!wrb)
+  if (!wrb) {
+    free(mbuf);
     return nullptr;
+  }
 
   if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, rb, -1, wrb,
                            ms.st_size + 1)) {
     LOG(("GetManifestContents: error converting utf8 to utf16le: %d", GetLastError()));
     free(mbuf);
     free(wrb);
     return nullptr;
   }