summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-07-30 08:58:39 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-07-30 08:58:39 -0700
commita82c88f98b5a176d62e0055ec9f475179acc313f (patch)
tree3dc08c7f59b7d9cef690fb9b5a85b583f3a7fdab /hash.c
parentd9cda87d916b668c6f5de7fbf6cf983cb6c737e2 (diff)
downloadtxr-a82c88f98b5a176d62e0055ec9f475179acc313f.tar.gz
txr-a82c88f98b5a176d62e0055ec9f475179acc313f.tar.bz2
txr-a82c88f98b5a176d62e0055ec9f475179acc313f.zip
Correction to COBJ initialization pattern.
In fact, the previosuly documented process is not correct and still leaves a corruption problem under generational GC (which has been the default for some time). * HACKING: Document flaw in the initialization pattern previously thought to be correct, and show fix. * hash.c (copy_hash): Fix instance of incorrect pattern. * regex.c (regex_compile): Likewise.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 4ece8a54..543c2d62 100644
--- a/hash.c
+++ b/hash.c
@@ -523,13 +523,14 @@ val copy_hash(val existing)
{
struct hash *ex = coerce(struct hash *, cobj_handle(existing, hash_s));
struct hash *h = coerce(struct hash *, chk_malloc(sizeof *h));
- val hash = cobj(coerce(mem_t *, h), hash_s, &hash_ops);
val mod = num_fast(ex->modulus);
+ val table = vector(mod, nil);
+ val hash = cobj(coerce(mem_t *, h), hash_s, &hash_ops);
val iter;
h->modulus = ex->modulus;
h->count = ex->count;
- h->table = vector(mod, nil);
+ h->table = table;
h->userdata = ex->userdata;
h->flags = ex->flags;