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

ruby-changes:50636

From: nobu <ko1@a...>
Date: Sat, 17 Mar 2018 20:42:13 +0900 (JST)
Subject: [ruby-changes:50636] nobu:r62796 (trunk): compile.c: resize to align offsets

nobu	2018-03-17 20:42:08 +0900 (Sat, 17 Mar 2018)

  New Revision: 62796

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

  Log:
    compile.c: resize to align offsets
    
    * compile.c (ibf_dump_align): resize the dump buffer.
      rb_str_modify_expand expands the buffer but not set the length.

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 62795)
+++ compile.c	(revision 62796)
@@ -8204,7 +8204,13 @@ ibf_dump_align(struct ibf_dump *dump, si https://github.com/ruby/ruby/blob/trunk/compile.c#L8204
 {
     ibf_offset_t pos = ibf_dump_pos(dump);
     if (pos % align) {
-        rb_str_modify_expand(dump->str, align - (pos % align));
+        long size = (long)pos - (pos % align) + align;
+#if SIZEOF_LONG > SIZEOF_INT
+        if (pos >= UINT_MAX) {
+            rb_raise(rb_eRuntimeError, "dump size exceeds");
+        }
+#endif
+        rb_str_resize(dump->str, size);
     }
 }
 
@@ -9553,6 +9559,10 @@ iseq_ibf_dump(const rb_iseq_t *iseq, VAL https://github.com/ruby/ruby/blob/trunk/compile.c#L9559
 static const ibf_offset_t *
 ibf_iseq_list(const struct ibf_load *load)
 {
+    if (load->header->iseq_list_offset % sizeof(ibf_offset_t)) {
+        rb_raise(rb_eArgError, "unaligned iseq list offset: %u",
+                 load->header->iseq_list_offset);
+    }
     return (ibf_offset_t *)(load->buff + load->header->iseq_list_offset);
 }
 

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

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