summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--io.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index f25845ed7d..54ac428281 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Oct 2 17:09:38 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fptr_finalize): free fptr to avoid memory leaks.
+ fixed: #2009 [ruby-core:25173] [ruby-dev:39410]
+
Fri Oct 2 13:54:46 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* eval.c (rb_origenviron): remove unused old variable.
diff --git a/io.c b/io.c
index 16cff98517..ffdaa539d5 100644
--- a/io.c
+++ b/io.c
@@ -2351,10 +2351,10 @@ rb_io_fptr_finalize(fptr)
if (fptr->path) {
free(fptr->path);
}
- if (!fptr->f && !fptr->f2) return;
- if (fileno(fptr->f) < 3) return;
-
- rb_io_fptr_cleanup(fptr, Qtrue);
+ if ((fptr->f && fileno(fptr->f) > 2) || fptr->f2) {
+ rb_io_fptr_cleanup(fptr, Qtrue);
+ }
+ xfree(fptr);
}
VALUE