ruby/ruby-1.8.5-hash-memory-leak.patch
2006-09-05 07:37:24 +00:00

49 lines
1.0 KiB
Diff

diff -ruN ruby-1.8.5.orig/hash.c ruby-1.8.5/hash.c
--- ruby-1.8.5.orig/hash.c 2006-07-07 00:44:26.000000000 +0900
+++ ruby-1.8.5/hash.c 2006-08-30 15:50:31.000000000 +0900
@@ -223,20 +223,31 @@
rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
}
+static VALUE hash_alloc0 _((VALUE));
static VALUE hash_alloc _((VALUE));
static VALUE
-hash_alloc(klass)
+hash_alloc0(klass)
VALUE klass;
{
NEWOBJ(hash, struct RHash);
OBJSETUP(hash, klass, T_HASH);
hash->ifnone = Qnil;
- hash->tbl = st_init_table(&objhash);
return (VALUE)hash;
}
+static VALUE
+hash_alloc(klass)
+ VALUE klass;
+{
+ VALUE hash = hash_alloc0(klass);
+
+ RHASH(hash)->tbl = st_init_table(&objhash);
+
+ return hash;
+}
+
VALUE
rb_hash_new()
{
@@ -325,9 +336,7 @@
int i;
if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- hash = hash_alloc(klass);
-
- RHASH(hash)->ifnone = Qnil;
+ hash = hash_alloc0(klass);
RHASH(hash)->tbl = st_copy(RHASH(argv[0])->tbl);
return hash;