summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-02 08:25:29 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-02 08:25:29 +0000
commit4b986d7ff494df21a59443ea3aa73b873216017f (patch)
tree5dae0ed03867bccf444410084fa7ed71e1b6a6d2
parentaf3460ef8cb371dad29c8c198ed4c0928278194c (diff)
* io.c (rb_io_fptr_finalize): free fptr to avoid memory leaks.
fixed: #2009 [ruby-core:25173] [ruby-dev:39410] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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