Skip to content

Commit 45c2b10

Browse files
committed
Fix debug assert when using instanceof if __proto__ was set to non-object (fix #2363)
1 parent a989280 commit 45c2b10

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
Add Serial.flush() to allow us to wait for transmission on a device to finish
2929
Fix for var link corruption when replacing a native function with a normal one (fix #2361)
3030
Fix memory leak (and assert in debug mode) when iterating over an object with proto with for...of (fix #2360)
31-
Fix assert when reversing an array with non-integer elements (fix #2362)
31+
Fix debug assert when reversing an array with non-integer elements (fix #2362)
32+
Fix debug assert when using instanceof if __proto__ was set to non-object (fix #2363)
3233

3334
2v17 : Bangle.js: When reading file info from a filename table, do it in blocks of 8 (20% faster file search)
3435
Bangle.js2: Increase flash buffer size from 16->32 bytes (5% performance increase)

src/jsparse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,15 +2063,15 @@ NO_INLINE JsVar *__jspeBinaryExpression(JsVar *a, unsigned int lastPrecedence) {
20632063
if (jsvIsObject(av) || jsvIsFunction(av)) {
20642064
JsVar *bproto = jspGetNamedField(bv, JSPARSE_PROTOTYPE_VAR, false);
20652065
JsVar *proto = jsvObjectGetChildIfExists(av, JSPARSE_INHERITS_VAR);
2066-
while (proto) {
2066+
while (jsvHasChildren(proto)) { // proto could have been set to anything (null/number/etc) #2363
20672067
if (proto == bproto) inst=true;
20682068
// search prototype chain
20692069
JsVar *childProto = jsvObjectGetChildIfExists(proto, JSPARSE_INHERITS_VAR);
20702070
jsvUnLock(proto);
20712071
proto = childProto;
20722072
}
20732073
if (jspIsConstructor(bv, "Object")) inst = true;
2074-
jsvUnLock(bproto);
2074+
jsvUnLock2(bproto, proto);
20752075
}
20762076
if (!inst) {
20772077
const char *name = jswGetBasicObjectName(av);

0 commit comments

Comments
 (0)