]> granicus.if.org Git - json-c/commitdiff
fix regression from 2d549662be832da838aa063da2efa78ee3b99668
authorRainer Gerhards <rgerhards@adiscon.com>
Thu, 19 Nov 2015 10:05:15 +0000 (11:05 +0100)
committerRainer Gerhards <rgerhards@adiscon.com>
Thu, 19 Nov 2015 10:05:15 +0000 (11:05 +0100)
That commit introduced read-only keys, but when the hash table
was resized, that attribute was not preserved. This resulted in
an invalid free at time of table destruction.

linkhash.c

index 9457fb75c01e142b8fa548e23f20fd59a1510ec3..e19297ee712c995c5838c751d573c57d45aa6204 100644 (file)
@@ -506,7 +506,9 @@ void lh_table_resize(struct lh_table *t, int new_size)
        new_t = lh_table_new(new_size, NULL, t->hash_fn, t->equal_fn);
        ent = t->head;
        while(ent) {
-               lh_table_insert(new_t, ent->k, ent->v);
+               lh_table_insert_w_hash(new_t, ent->k, ent->v,
+                       lh_get_hash(new_t, ent->k),
+                       (ent->k_is_constant) ? JSON_C_OBJECT_KEY_IS_CONSTANT : 0 );
                ent = ent->next;
        }
        free(t->table);