From 7eeaf208b484f257bc6c04e4229cb924e00a18c1 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 25 Jun 2014 22:43:23 +0000 Subject: [PATCH] hash.c: fix dangling pointer * hash.c (env_name): also store a coerced string to get rid of a dangling pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hash.c b/hash.c index d6ac93fbc7..56cedf072b 100644 --- a/hash.c +++ b/hash.c @@ -2547,14 +2547,16 @@ env_str_new2(const char *ptr) rb_raise(rb_eArgError, "bad environment variable " #var) : (void)0) static inline const char * -env_name(VALUE s) +env_name(volatile VALUE *s) { const char *name; - SafeStringValue(s); - get_env_ptr(name, s); + SafeStringValue(*s); + get_env_ptr(name, *s); return name; } +#define env_name(s) env_name(&(s)) + static VALUE env_delete(VALUE obj, VALUE name) {