aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/file.c b/file.c
index 20f0d791a8..719bb27557 100644
--- a/file.c
+++ b/file.c
@@ -2009,6 +2009,10 @@ rb_stat_init(obj, fname)
if (stat(RSTRING(fname)->ptr, &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
+ if (DATA_PTR(obj)) {
+ free(DATA_PTR(obj));
+ DATA_PTR(obj) = NULL;
+ }
nst = ALLOC(struct stat);
*nst = st;
DATA_PTR(obj) = nst;