[前][次][番号順一覧][スレッド一覧]

ruby-changes:34475

From: nobu <ko1@a...>
Date: Thu, 26 Jun 2014 07:43:31 +0900 (JST)
Subject: [ruby-changes:34475] nobu:r46556 (trunk): hash.c: fix dangling pointer

nobu	2014-06-26 07:43:23 +0900 (Thu, 26 Jun 2014)

  New Revision: 46556

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46556

  Log:
    hash.c: fix dangling pointer
    
    * hash.c (env_name): also store a coerced string to get rid of a
      dangling pointer.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 46555)
+++ hash.c	(revision 46556)
@@ -2547,14 +2547,16 @@ env_str_new2(const char *ptr) https://github.com/ruby/ruby/blob/trunk/hash.c#L2547
      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)
 {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]