Skip to content

Commit

Permalink
Fix potential for crash after ReferenceError during function declarat…
Browse files Browse the repository at this point in the history
…ion (fix #2457)
  • Loading branch information
gfwilliams committed Jan 31, 2024
1 parent 372d4af commit 5fee08f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Fix issue with g.wrapString when running on flash-based strings
Fix lock leak when using flat/flash/native strings as object indices
Fix g.wrapString lockup if wrap width is less than the character width
Fix potential for crash after ReferenceError during function declaration (fix #2457)

2v20 : Ensure String.charCodeAt returns NaN for out of bounds chars
Bangle.js2: When rendering overlays, *do not* use the current FG/BG color for 1 bit overlays
Expand Down
7 changes: 5 additions & 2 deletions src/jsparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,9 +1319,12 @@ NO_INLINE JsVar *jspeFactorFunctionCall() {
while ((lex->tk=='(' || (isConstructor && JSP_SHOULD_EXECUTE)) && !jspIsInterrupted()) {
JsVar *funcName = a;
JsVar *func = jsvSkipName(funcName);

if (!func) { // could have ReferenceErrored while skipping name
jsvUnLock2(funcName, parent);
return 0;
}
/* The constructor function doesn't change parsing, so if we're
* not executing, just short-cut it. */
* not executing, just short-cut it. */
if (isConstructor && JSP_SHOULD_EXECUTE) {
// If we have '(' parse an argument list, otherwise don't look for any args
bool parseArgs = lex->tk=='(';
Expand Down

0 comments on commit 5fee08f

Please sign in to comment.