summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-27 19:01:31 +0000
committerwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-27 19:01:31 +0000
commitfdbf2bb474d7c1922fb66d433de21bfa99b2d471 (patch)
tree91a811eee82a4c6feef2d230d06d0129a96b76f5 /io.c
parent8bebedc59761f4ca767e1a2d7db20758f279bf90 (diff)
Backport #2009 [ruby-core:25173]; (rb_io_fptr_finalize): free fptr to avoid memory leaks.
My brain got stuck in a bad pattern, and I kept adding new items under the first record for the day. They are all broken out into their own entries like they should be, now, with timestamps pulled from the SVN log. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@26457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/io.c b/io.c
index 360cbd4b97..dc06d1062e 100644
--- a/io.c
+++ b/io.c
@@ -2230,10 +2230,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