From c9c3c42c22a2653c522136d5109b74df1772b270 Mon Sep 17 00:00:00 2001
From: Matthew Gaudet <mgaudet@mozilla.com>
Date: Thu, 7 Mar 2024 15:24:04 +0000
Subject: [PATCH] Bug 1860193 - Verify we get a script from a function before
 asking for the filename r=mccr8, a=RyanVM

Differential Revision: https://phabricator.services.mozilla.com/D203836
---
 js/xpconnect/src/XPCComponents.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp
index 77df85b5f8024..b69aaea0b5c21 100644
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -1789,7 +1789,7 @@ nsXPCComponents_Utils::GetFunctionSourceLocation(HandleValue funcValue,
     NS_ENSURE_TRUE(func, NS_ERROR_INVALID_ARG);
 
     RootedScript script(cx, JS_GetFunctionScript(cx, func));
-    NS_ENSURE_TRUE(func, NS_ERROR_FAILURE);
+    NS_ENSURE_TRUE(script, NS_ERROR_FAILURE);
 
     AppendUTF8toUTF16(nsDependentCString(JS_GetScriptFilename(script)),
                       filename);
-- 
GitLab