mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Fix an assert fail, and handle some potential memory leaks
This commit is contained in:
parent
2c32b2f4cd
commit
e43f2d130e
@ -3,7 +3,8 @@
|
||||
Implement 'String' constructor in the normal way (fix #110)
|
||||
Fix regression with parsing constructors while not executing
|
||||
Allow multiple arguments to print and console.log (fix #92)
|
||||
make 'arguments' array available in functions (fix #100)
|
||||
Make 'arguments' array available in functions (fix #100)
|
||||
Fix an assert fail, and handle some potential memory leaks
|
||||
|
||||
1v41 : Fix Olimexino compile (https://github.com/espruino/Espruino/issues/6)
|
||||
[ebirger] Member constructors (eg. new a.b() )
|
||||
|
||||
@ -184,6 +184,7 @@ def codeOutFunction(indent, func):
|
||||
codeOut(indent+"jspParseEmptyFunction();")
|
||||
elif len(params)==1 and params[0][1]=="JsVarArray":
|
||||
codeOut(indent+"JsVar *"+params[0][0]+" = jspParseFunctionAsArray();")
|
||||
codeOut(indent+"if (!"+params[0][0]+") return 0; // if parse error")
|
||||
elif len(params)==1 and params[0][1]!="JsVarName":
|
||||
codeOut(indent+"JsVar *"+params[0][0]+" = jspParseSingleFunction();")
|
||||
elif len(params)<9:
|
||||
|
||||
@ -381,14 +381,14 @@ JsVar *jspParseFunctionAsArray() {
|
||||
JSP_MATCH(LEX_ID);
|
||||
JsVar *arr = jsvNewWithFlags(JSV_ARRAY);
|
||||
if (!arr) return 0; // out of memory
|
||||
JSP_MATCH('(');
|
||||
while (execInfo.lex->tk!=')' && execInfo.lex->tk!=LEX_EOF) {
|
||||
JSP_MATCH_WITH_CLEANUP_AND_RETURN('(', jsvUnLock(arr), 0);
|
||||
while (!JSP_HAS_ERROR && execInfo.lex->tk!=')' && execInfo.lex->tk!=LEX_EOF) {
|
||||
JsVar *arg = jsvSkipNameAndUnLock(jspeBase());
|
||||
jsvArrayPush(arr, arg); // even if undefined
|
||||
jsvUnLock(arg);
|
||||
if (execInfo.lex->tk!=')') JSP_MATCH(',');
|
||||
if (execInfo.lex->tk!=')') JSP_MATCH_WITH_CLEANUP_AND_RETURN(',', jsvUnLock(arr), 0);
|
||||
}
|
||||
JSP_MATCH(')');
|
||||
JSP_MATCH_WITH_CLEANUP_AND_RETURN(')', jsvUnLock(arr), 0);
|
||||
return arr;
|
||||
}
|
||||
|
||||
@ -1653,7 +1653,7 @@ JsVar *jspeStatementSwitch() {
|
||||
jsvUnLock(test);
|
||||
if (cond && (execInfo.execute&EXEC_RUN_MASK)==EXEC_NO)
|
||||
execInfo.execute=EXEC_YES|EXEC_IN_SWITCH;
|
||||
while (execInfo.lex->tk!=LEX_EOF && execInfo.lex->tk!=LEX_R_CASE && execInfo.lex->tk!=LEX_R_DEFAULT && execInfo.lex->tk!='}')
|
||||
while (!JSP_HAS_ERROR && execInfo.lex->tk!=LEX_EOF && execInfo.lex->tk!=LEX_R_CASE && execInfo.lex->tk!=LEX_R_DEFAULT && execInfo.lex->tk!='}')
|
||||
jsvUnLock(jspeBlockOrStatement());
|
||||
}
|
||||
jsvUnLock(switchOn);
|
||||
@ -1666,7 +1666,7 @@ JsVar *jspeStatementSwitch() {
|
||||
JSP_MATCH(':');
|
||||
JSP_SAVE_EXECUTE();
|
||||
if (hasExecuted) jspSetNoExecute();
|
||||
while (execInfo.lex->tk!=LEX_EOF && execInfo.lex->tk!='}')
|
||||
while (!JSP_HAS_ERROR && execInfo.lex->tk!=LEX_EOF && execInfo.lex->tk!='}')
|
||||
jsvUnLock(jspeBlockOrStatement());
|
||||
JSP_RESTORE_EXECUTE();
|
||||
}
|
||||
|
||||
8
tests/test_ternary_broken.js
Normal file
8
tests/test_ternary_broken.js
Normal file
@ -0,0 +1,8 @@
|
||||
// This used to cause an assert fail...
|
||||
|
||||
result=1;
|
||||
print("ERROR IS EXPECTED!");
|
||||
function a(a) { print(a==undefined:"un":a); }
|
||||
a();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user