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

ruby-changes:1673

From: ko1@a...
Date: 22 Aug 2007 09:56:26 +0900
Subject: [ruby-changes:1673] shyouhei - Ruby:r13164 (ruby_1_8_6): * struct.c (rb_struct_init_copy): disallow changing the size.

shyouhei	2007-08-22 09:56:18 +0900 (Wed, 22 Aug 2007)

  New Revision: 13164

  Modified files:
    branches/ruby_1_8_6/ChangeLog
    branches/ruby_1_8_6/struct.c
    branches/ruby_1_8_6/version.h

  Log:
    * struct.c (rb_struct_init_copy): disallow changing the size.
      [ruby-dev:31168]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/ChangeLog?r1=13164&r2=13163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/version.h?r1=13164&r2=13163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/struct.c?r1=13164&r2=13163

Index: ruby_1_8_6/ChangeLog
===================================================================
--- ruby_1_8_6/ChangeLog	(revision 13163)
+++ ruby_1_8_6/ChangeLog	(revision 13164)
@@ -1,3 +1,8 @@
+Wed Aug 22 09:55:08 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* struct.c (rb_struct_init_copy): disallow changing the size.
+	  [ruby-dev:31168]
+
 Wed Aug 22 09:54:28 2007  NAKAMURA, Hiroshi  <nahi@r...>
 
 	* random.c: documentation fix.  srand(0) initializes PRNG with '0',
Index: ruby_1_8_6/version.h
===================================================================
--- ruby_1_8_6/version.h	(revision 13163)
+++ ruby_1_8_6/version.h	(revision 13164)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2007-08-22"
 #define RUBY_VERSION_CODE 186
 #define RUBY_RELEASE_CODE 20070822
-#define RUBY_PATCHLEVEL 56
+#define RUBY_PATCHLEVEL 57
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_6/struct.c
===================================================================
--- ruby_1_8_6/struct.c	(revision 13163)
+++ ruby_1_8_6/struct.c	(revision 13164)
@@ -252,7 +252,7 @@
     ary = rb_ary_new();
 
     va_init_list(ar, name);
-    while (mem = va_arg(ar, char*)) {
+    while ((mem = va_arg(ar, char*)) != 0) {
 	ID slot = rb_intern(mem);
 	rb_ary_push(ary, ID2SYM(slot));
     }
@@ -557,8 +557,9 @@
     if (!rb_obj_is_instance_of(s, rb_obj_class(copy))) {
 	rb_raise(rb_eTypeError, "wrong argument class");
     }
-    RSTRUCT(copy)->ptr = ALLOC_N(VALUE, RSTRUCT(s)->len);
-    RSTRUCT(copy)->len = RSTRUCT(s)->len;
+    if (RSTRUCT(copy)->len != RSTRUCT(s)->len) {
+	rb_raise(rb_eTypeError, "struct size mismatch");
+    }
     MEMCPY(RSTRUCT(copy)->ptr, RSTRUCT(s)->ptr, VALUE, RSTRUCT(copy)->len);
 
     return copy;

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

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