Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hash part handling in enum sorting #2322

Merged
merged 1 commit into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions releases/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1365,3 +1365,4 @@ duktape_releases:
- "Fix nested error handling bug for out-of-memory during error creation (GH-2278, GH-2290)"
- "Fix failing assert for CBOR.encode() when argument is a zero-size dynamic plain array (GH-2316, GH-2318)"
- "Fix pointer overflow in String.prototype.startsWith/endsWith() with certain arguments (GH-2320)"
- "Fix assertion failure and incorrect behavior in some enumeration cases involving inherited duplicate keys (GH-2322)"
7 changes: 7 additions & 0 deletions src-input/duk_hobject_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ DUK_LOCAL void duk__sort_enum_keys_es6(duk_hthread *thr, duk_hobject *h_obj, duk
keys[idx_insert] = h_curr;
}
}

/* Entry part has been reordered now with no side effects.
* If the object has a hash part, it will now be incorrect
* and we need to rehash. Do that by forcing a resize to
* the current size.
*/
duk_hobject_resize_entrypart(thr, h_obj, DUK_HOBJECT_GET_ESIZE(h_obj));
}

/*
Expand Down
18 changes: 18 additions & 0 deletions tests/ecmascript/test-bug-assert-property-add-gh2315.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// https://github.com/svaarala/duktape/issues/2315

/*===
done
===*/

function main() {
var v1 = [13.37,13.37,13.37];
var v2 = [13.37];
var v3 = {a:v2,length:v2};
var v4 = v3;
v4.__proto__ = v1;
var v5 = v4.sort();
for (var v6 in v5) {
}
}
main();
print('done');