diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 1fd2ae4b409..72f3aa402e5 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2941,11 +2941,14 @@ nsDocShell::PopProfileTimelineMarkers(JSContext* aCx, } } - ToJSValue(aCx, profileTimelineMarkers, aProfileTimelineMarkers); - ClearProfileTimelineMarkers(); mProfileTimelineMarkers.SwapElements(keptMarkers); + if (!ToJSValue(aCx, profileTimelineMarkers, aProfileTimelineMarkers)) { + JS_ClearPendingException(aCx); + return NS_ERROR_UNEXPECTED; + } + return NS_OK; #else return NS_ERROR_FAILURE;