aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-04-09 17:20:23 +0200
committerSverker Eriksson <[email protected]>2015-04-09 17:20:23 +0200
commitf54392bc3c811d44cef2b31c20cac9fb11bf38e1 (patch)
tree7a9df9126318c4858bee2d024936c240c24be686 /erts
parent26c94c98a598a312b7912b1ef7ae3a7b01abcbf1 (diff)
parente3f21d4911117b80e80ea4a07f3532ad39ede16b (diff)
downloadotp-f54392bc3c811d44cef2b31c20cac9fb11bf38e1.tar.gz
otp-f54392bc3c811d44cef2b31c20cac9fb11bf38e1.tar.bz2
otp-f54392bc3c811d44cef2b31c20cac9fb11bf38e1.zip
Merge branch 'sverk/maps-bin2term-eqhash-bug/12585'
* sverk/maps-bin2term-eqhash-bug/12585: erts: Fix bug in map_from_list when keys clash in both value and hash erts: Fix bug in binary_to_term for big maps with 32 bit hash-clash
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_map.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c
index cca287c753..d1df737723 100644
--- a/erts/emulator/beam/erl_map.c
+++ b/erts/emulator/beam/erl_map.c
@@ -568,14 +568,14 @@ static Eterm hashmap_from_unsorted_array(ErtsHeapFactory* factory,
while(ix < jx) {
lx = ix;
- while(ix < jx && EQ(CAR(list_val(hxns[ix].val)), CAR(list_val(hxns[lx].val)))) {
+ while(++ix < jx && EQ(CAR(list_val(hxns[ix].val)),
+ CAR(list_val(hxns[lx].val)))) {
if (reject_dupkeys)
return THE_NON_VALUE;
if (hxns[ix].i > hxns[lx].i) {
lx = ix;
}
- ix++;
}
hxns[cx].hx = hxns[lx].hx;
hxns[cx].val = hxns[lx].val;
@@ -860,7 +860,12 @@ static Eterm hashmap_from_chunked_array(ErtsHeapFactory *factory, hxnode_t *hxns
#undef HALLOC_EXTRA
static int hxnodecmpkey(hxnode_t *a, hxnode_t *b) {
- return CMP_TERM(CAR(list_val(a->val)), CAR(list_val(b->val)));
+ Sint c = CMP_TERM(CAR(list_val(a->val)), CAR(list_val(b->val)));
+#if ERTS_SIZEOF_ETERM <= SIZEOF_INT
+ return c;
+#else
+ return c > 0 ? 1 : (c < 0 ? -1 : 0);
+#endif
}
static int hxnodecmp(hxnode_t *a, hxnode_t *b) {