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 293166 ea7e3da670d6a6bd3e358319133bbef0e2f24186
parent 293165 04f9767b4abe6e33d294b89ab29ae5c1b2b67484
child 293167 dbb14513cb83681e2c2832c712b95c23bc9bf468
push id30177
push usercbook@mozilla.com
push dateFri, 15 Apr 2016 09:40:05 +0000
treeherdermozilla-central@755a175b3cc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1247217, 749520
milestone48.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 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;
   }