Bug 1226119 - Clear pending exception from script cache writing failure. r=bholley

This commit is contained in:
Mike Hommey
2015-11-20 10:11:30 +09:00
parent 232276cccd
commit aabc33f248

View File

@@ -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);