Fix regression where accessing certain member names of an undefined variable would cause a crash (fix #488)

This commit is contained in:
Gordon Williams 2015-02-02 16:53:41 +00:00
parent 17b6c3f333
commit b314d15d7a
3 changed files with 17 additions and 2 deletions

View File

@ -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)

View File

@ -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)) {

View 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;
}