Skip to content

Commit

Permalink
Fix asan errors by assigning before assigning hh_next
Browse files Browse the repository at this point in the history
It worked fine most of the time, just had issues when you tried to free
the entries while iterating. If you tried to free what held the next
reference ASAN would complain, and would likely cause issues in the
future.
  • Loading branch information
samcv committed Jul 9, 2018
1 parent 2686043 commit ed7ab67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/strings/uthash.h
Expand Up @@ -636,13 +636,13 @@ MVM_STATIC_INLINE void * HASH_ITER_FIRST_ITEM(
#define HASH_ITER_FAST(tc, hh, hash, current, code) do {\
unsigned bucket_tmp = 0;\
struct UT_hash_table *ht;\
if (hash && (ht = hash->hash_handle.tbl)) {\
if (hash && (ht = hash->hh.tbl)) {\
while (bucket_tmp < ht->num_buckets) {\
struct UT_hash_handle *current_hh = ht->buckets[bucket_tmp].hh_head;\
while (current_hh) {\
current = ELMT_FROM_HH(ht, current_hh);\
code \
current_hh = current_hh->hh_next;\
code \
}\
(bucket_tmp)++;\
}\
Expand All @@ -652,14 +652,14 @@ MVM_STATIC_INLINE void * HASH_ITER_FIRST_ITEM(
#define HASH_ITER(tc, hh, hash, current, code) do { \
unsigned bucket_tmp = 0; \
struct UT_hash_table *ht; \
if (hash && (ht = hash->hash_handle.tbl)) { \
if (hash && (ht = hash->hh.tbl)) { \
while (bucket_tmp < ht->num_buckets) { \
struct UT_hash_handle *current_hh = \
ht->buckets[GET_PRAND_BKT(bucket_tmp, ht)].hh_head; \
while (current_hh) {\
current = ELMT_FROM_HH(ht, current_hh); \
code \
current_hh = current_hh->hh_next; \
code \
} \
(bucket_tmp)++; \
} \
Expand Down

0 comments on commit ed7ab67

Please sign in to comment.