mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Fix regression where accessing certain member names of an undefined variable would cause a crash (fix #488)
This commit is contained in:
parent
17b6c3f333
commit
b314d15d7a
@ -1,4 +1,5 @@
|
||||
1v73 : Add Uint8ClampedArray, remove code duplication in ArrayBuffer (fix #486)
|
||||
Fix regression where accessing certain member names of an undefined variable would cause a crash (fix #488)
|
||||
|
||||
1v72 : Stop RTC being reset by hard reset (getTime will now be time since power first applied) (fix #412)
|
||||
Allow Function.apply to take typed arrays (fix #442)
|
||||
|
||||
@ -846,7 +846,9 @@ NO_INLINE JsVar *jspeFactorMember(JsVar *a, JsVar **parentResult) {
|
||||
const char *name = jslGetTokenValueAsString(execInfo.lex);
|
||||
|
||||
JsVar *aVar = jsvSkipName(a);
|
||||
JsVar *child = jspGetNamedField(aVar, name, true);
|
||||
JsVar *child = 0;
|
||||
if (aVar)
|
||||
child = jspGetNamedField(aVar, name, true);
|
||||
if (!child) {
|
||||
if (jsvHasChildren(aVar)) {
|
||||
// if no child found, create a pointer to where it could be
|
||||
@ -877,7 +879,9 @@ NO_INLINE JsVar *jspeFactorMember(JsVar *a, JsVar **parentResult) {
|
||||
if (JSP_SHOULD_EXECUTE) {
|
||||
index = jsvAsArrayIndexAndUnLock(index);
|
||||
JsVar *aVar = jsvSkipName(a);
|
||||
JsVar *child = jspGetVarNamedField(aVar, index, true);
|
||||
JsVar *child = 0;
|
||||
if (aVar)
|
||||
child = jspGetVarNamedField(aVar, index, true);
|
||||
|
||||
if (!child) {
|
||||
if (jsvHasChildren(aVar)) {
|
||||
|
||||
10
tests/test_member_of_undefined.js
Normal file
10
tests/test_member_of_undefined.js
Normal file
@ -0,0 +1,10 @@
|
||||
// https://github.com/espruino/Espruino/issues/488
|
||||
// Espruino locks up if a known module name is used as an unknown module method or property
|
||||
|
||||
try {
|
||||
a.E
|
||||
a["E"]
|
||||
} catch (e) {
|
||||
result=1;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user