From db663c43dee33d7473db7492222b99cdaf34c1ff Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 9 Jul 2020 06:42:04 -0700 Subject: 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. --- sysif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sysif.c') diff --git a/sysif.c b/sysif.c index 4d1a8b6d..6af1aca2 100644 --- a/sysif.c +++ b/sysif.c @@ -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; } } -- cgit v1.2.3