Skip to content

Commit

Permalink
Merge branch 'sverk/maps-bin2term-eqhash-bug/12585'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sverker committed Apr 9, 2015
2 parents 26c94c9 + e3f21d4 commit f54392b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions erts/emulator/beam/erl_map.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f54392b

Please sign in to comment.