Fix double free when getcwd does not allocate buffer

Do not free the result at normal return from `ruby_getcwd`.
This commit is contained in:
Nobuyoshi Nakada 2024-07-17 15:16:21 +09:00
parent 05502c1dda
commit 03a0ade90d
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2024-07-17 07:17:42 +00:00

2
util.c
View File

@ -564,7 +564,7 @@ ruby_getcwd(void)
rb_imemo_tmpbuf_set_ptr(guard, buf);
buf = xrealloc(buf, size);
}
rb_free_tmp_buffer(&guard);
rb_imemo_tmpbuf_set_ptr(guard, NULL);
return buf;
}