diff --git a/ChangeLog b/ChangeLog index 6786ef5586..f64fa85914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 19 15:34:40 2009 Yukihiro Matsumoto + + * io.c (rb_io_fptr_finalize): free fptr to avoid memory leaks. + fixed: #2009 [ruby-core:25173] [ruby-dev:39410] + Thu Nov 19 15:27:17 2009 Marc-Andre Lafortune * lib/net/http.rb (transport_request): Handle timeout error by diff --git a/io.c b/io.c index b295d102ad..1bdb5ec2c9 100644 --- a/io.c +++ b/io.c @@ -2334,10 +2334,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 diff --git a/version.h b/version.h index 500d79fae7..30d64c5d5c 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2009-11-19" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20091119 -#define RUBY_PATCHLEVEL 213 +#define RUBY_PATCHLEVEL 214 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8