Bug 1022954 - ScriptSource leaks sourceMapURL_ sometimes. r=jimb

This commit is contained in:
Andrew McCreight 2014-07-10 15:46:00 +02:00
parent 32b182c4a7
commit 60a9b99fa1
3 changed files with 11 additions and 11 deletions

View File

@ -65,9 +65,6 @@ leak:AllocateArrayBufferContents
# Bug 1022010 - Small leak under _render_glyph_outline. bc1
leak:_render_glyph_outline
# Bug 1022954 - ScriptSource leaks sourceMapURL_ sometimes. dt
leak:ScriptSource::setSourceMapURL
# Bug 1023548 - Small leak under SECITEM_AllocItem_Util. bc1, bc3
leak:SECITEM_AllocItem_Util

View File

@ -1,4 +1,4 @@
//@ sourceMappingURL=bar.js.map
//# sourceMappingURL=bar.js.map
// Define a single function to prevent script source from being gc'd
function foo() {}

View File

@ -1864,6 +1864,7 @@ ScriptSource::performXDR(XDRState<mode> *xdr)
if (mode == XDR_DECODE) {
size_t byteLen = (sourceMapURLLen + 1) * sizeof(jschar);
MOZ_ASSERT(!sourceMapURL_, "Don't leak sourceMapURL_");
sourceMapURL_ = static_cast<jschar *>(xdr->cx()->malloc_(byteLen));
if (!sourceMapURL_)
return false;
@ -2035,14 +2036,16 @@ ScriptSource::setSourceMapURL(ExclusiveContext *cx, const jschar *sourceMapURL)
{
JS_ASSERT(sourceMapURL);
if (hasSourceMapURL()) {
if (cx->isJSContext() &&
!JS_ReportErrorFlagsAndNumber(cx->asJSContext(), JSREPORT_WARNING,
js_GetErrorMessage, nullptr,
JSMSG_ALREADY_HAS_PRAGMA, filename_,
"//# sourceMappingURL"))
{
return false;
// Warn about the replacement, but use the new one.
if (cx->isJSContext()) {
JS_ReportErrorFlagsAndNumber(cx->asJSContext(), JSREPORT_WARNING,
js_GetErrorMessage, nullptr,
JSMSG_ALREADY_HAS_PRAGMA, filename_,
"//# sourceMappingURL");
}
js_free(sourceMapURL_);
sourceMapURL_ = nullptr;
}
size_t len = js_strlen(sourceMapURL) + 1;