Skip to content

Commit 7eeaf20

Browse files
committed
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
1 parent 0e198d3 commit 7eeaf20

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hash.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,14 +2547,16 @@ env_str_new2(const char *ptr)
25472547
rb_raise(rb_eArgError, "bad environment variable " #var) : (void)0)
25482548

25492549
static inline const char *
2550-
env_name(VALUE s)
2550+
env_name(volatile VALUE *s)
25512551
{
25522552
const char *name;
2553-
SafeStringValue(s);
2554-
get_env_ptr(name, s);
2553+
SafeStringValue(*s);
2554+
get_env_ptr(name, *s);
25552555
return name;
25562556
}
25572557

2558+
#define env_name(s) env_name(&(s))
2559+
25582560
static VALUE
25592561
env_delete(VALUE obj, VALUE name)
25602562
{

0 commit comments

Comments
 (0)