Bug 1187450 - avoid leaking cstr in SPSProfiler::allocProfileString. r=jorendorff
authorBogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Tue, 23 Feb 2016 11:12:35 +0200
changeset 321775 84ba22179d9775a7b79e78df2a9e099ba18ebaac
parent 321774 6ba4a380e9020f75cf016ca358c3982031385434
child 321776 07f601e5ce85d64f01434cacd3361c21b5e73e33
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1187450
milestone47.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 1187450 - avoid leaking cstr in SPSProfiler::allocProfileString. r=jorendorff MozReview-Commit-ID: GtBKL4M2hfm
js/src/vm/SPSProfiler.cpp
--- a/js/src/vm/SPSProfiler.cpp
+++ b/js/src/vm/SPSProfiler.cpp
@@ -345,18 +345,20 @@ SPSProfiler::allocProfileString(JSScript
     char* cstr = js_pod_malloc<char>(len + 1);
     if (cstr == nullptr)
         return nullptr;
 
     // Construct the descriptive string.
     DebugOnly<size_t> ret;
     if (atom) {
         UniqueChars atomStr = StringToNewUTF8CharsZ(nullptr, *atom);
-        if (!atomStr)
+        if (!atomStr) {
+            js_free(cstr);
             return nullptr;
+        }
         ret = JS_snprintf(cstr, len + 1, "%s (%s:%" PRIu64 ")", atomStr.get(), filename, lineno);
     } else {
         ret = JS_snprintf(cstr, len + 1, "%s:%" PRIu64, filename, lineno);
     }
 
     MOZ_ASSERT(ret == len, "Computed length should match actual length!");
 
     return cstr;