Bug 1226119 - Clear pending exception from script cache writing failure. r=bholley
This commit is contained in:
@@ -65,8 +65,11 @@ WriteCachedScript(StartupCache* cache, nsACString& uri, JSContext* cx,
|
|||||||
|
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
void* data = JS_EncodeScript(cx, script, &size);
|
void* data = JS_EncodeScript(cx, script, &size);
|
||||||
if (!data)
|
if (!data) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
// JS_EncodeScript may have set a pending exception.
|
||||||
|
JS_ClearPendingException(cx);
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(size);
|
MOZ_ASSERT(size);
|
||||||
nsresult rv = cache->PutBuffer(PromiseFlatCString(uri).get(), static_cast<char*>(data), size);
|
nsresult rv = cache->PutBuffer(PromiseFlatCString(uri).get(), static_cast<char*>(data), size);
|
||||||
@@ -83,8 +86,11 @@ WriteCachedFunction(StartupCache* cache, nsACString& uri, JSContext* cx,
|
|||||||
uint32_t size;
|
uint32_t size;
|
||||||
void* data =
|
void* data =
|
||||||
JS_EncodeInterpretedFunction(cx, JS_GetFunctionObject(function), &size);
|
JS_EncodeInterpretedFunction(cx, JS_GetFunctionObject(function), &size);
|
||||||
if (!data)
|
if (!data) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
// JS_EncodeInterpretedFunction may have set a pending exception.
|
||||||
|
JS_ClearPendingException(cx);
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(size);
|
MOZ_ASSERT(size);
|
||||||
nsresult rv = cache->PutBuffer(PromiseFlatCString(uri).get(), static_cast<char*>(data), size);
|
nsresult rv = cache->PutBuffer(PromiseFlatCString(uri).get(), static_cast<char*>(data), size);
|
||||||
|
|||||||
Reference in New Issue
Block a user