summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-12 13:11:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-12 13:11:11 +0000
commit2f3b28c682fe3010ed3b8803199616c12b52512d (patch)
tree8d902a2523cb232f24e07acfceb7edd3af86cd52
parentbe711df831c907551429345a91b1a07ff90be738 (diff)
string.c: clear env self in symbol proc
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear caller's self which is useless, so that it can get collected. [Fixes GH-592] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--internal.h1
-rw-r--r--proc.c11
-rw-r--r--string.c1
4 files changed, 19 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e49490..cfd1268 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Apr 12 22:11:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
+ caller's self which is useless, so that it can get collected.
+ [Fixes GH-592]
+
Sat Apr 12 09:26:48 2014 Eric Hodel <drbrain@segment7.net>
* ext/openssl/ossl_ocsp.c: [DOC] Document OpenSSL::OCSP.
diff --git a/internal.h b/internal.h
index 6c2951f..5890fdb 100644
--- a/internal.h
+++ b/internal.h
@@ -758,6 +758,7 @@ ID rb_id_attrget(ID id);
VALUE rb_proc_location(VALUE self);
st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
int rb_block_arity(void);
+VALUE rb_block_clear_env_self(VALUE proc);
/* process.c */
#define RB_MAX_GROUPS (65536)
diff --git a/proc.c b/proc.c
index b36c7aa..1271a3b 100644
--- a/proc.c
+++ b/proc.c
@@ -710,6 +710,17 @@ rb_block_lambda(void)
}
VALUE
+rb_block_clear_env_self(VALUE proc)
+{
+ rb_proc_t *po;
+ rb_env_t *env;
+ GetProcPtr(proc, po);
+ GetEnvPtr(po->envval, env);
+ env->env[0] = Qnil;
+ return proc;
+}
+
+VALUE
rb_f_lambda(void)
{
rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
diff --git a/string.c b/string.c
index 56b27d9..28b1efa 100644
--- a/string.c
+++ b/string.c
@@ -8506,6 +8506,7 @@ sym_to_proc(VALUE sym)
}
else {
proc = rb_proc_new(sym_call, (VALUE)id);
+ rb_block_clear_env_self(proc);
aryp[index] = sym;
aryp[index + 1] = proc;
return proc;