diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-07-09 06:42:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-07-09 06:42:04 -0700 |
commit | c5fccc92682bd7c2ac63c483dea02111d0ecc720 (patch) | |
tree | 80f661f8afc0827325ffa307b18bb4aece701dd2 | |
parent | 755b199afdf2e54d7a5f19f6198e9304e055b36c (diff) | |
download | txr-c5fccc92682bd7c2ac63c483dea02111d0ecc720.tar.gz txr-c5fccc92682bd7c2ac63c483dea02111d0ecc720.tar.bz2 txr-c5fccc92682bd7c2ac63c483dea02111d0ecc720.zip |
opendir: gc-correctness.
* sysif.c (opendir_wrap): Store path into d->path after
allocating the cobj, because d->path may be the only reference
to that object, and the cobj call may trigger gc.
-rw-r--r-- | sysif.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -2255,9 +2255,10 @@ static val opendir_wrap(val path, val prefix_p) path, num(errno), errno_to_str(errno), nao); } else { struct dir *d = coerce(struct dir *, chk_malloc(sizeof *d)); + val obj = cobj(coerce(mem_t *, d), dir_s, &opendir_ops); d->dir = dir; d->path = if2(default_null_arg(prefix_p), path); - return cobj(coerce(mem_t *, d), dir_s, &opendir_ops); + return obj; } } |