Skip to content

Commit

Permalink
jsvObjectIterator is now safe even if not called on something iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 10, 2024
1 parent d93c223 commit b88a4d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Fix debugging of switch statements (fix #2562)
Network: enable parsing of 'https' URL and TLS flag even even TLS not built in (#2410)
removeListener while executing events no longer stops subsequent listeners from executing (#2151)
jsvObjectIterator is now safe even if not called on something iterable

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Expand Down
6 changes: 3 additions & 3 deletions src/jsvariterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,14 @@ void jsvStringIteratorAppendString(JsvStringIterator *it, JsVar *str, size_t sta
// --------------------------------------------------------------------------------------------

void jsvObjectIteratorNew(JsvObjectIterator *it, JsVar *obj) {
assert(jsvIsArray(obj) || jsvIsObject(obj) || jsvIsFunction(obj) || jsvIsGetterOrSetter(obj));
it->var = jsvLockSafe(jsvGetFirstChild(obj));
assert(!obj || jsvHasChildren(obj));
it->var = jsvHasChildren(obj) ? jsvLockSafe(jsvGetFirstChild(obj)) : 0;
}

/// Clone the iterator
void jsvObjectIteratorClone(JsvObjectIterator *dstit, JsvObjectIterator *it) {
*dstit = *it;
if (dstit->var) jsvLockAgain(dstit->var);
jsvLockAgainSafe(dstit->var);
}

/// Move to next item
Expand Down

0 comments on commit b88a4d1

Please sign in to comment.