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

ruby-changes:50912

From: nobu <ko1@a...>
Date: Sun, 8 Apr 2018 20:12:22 +0900 (JST)
Subject: [ruby-changes:50912] nobu:r63119 (trunk): compile.c: fix an exception argument

nobu	2018-04-08 20:12:17 +0900 (Sun, 08 Apr 2018)

  New Revision: 63119

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

  Log:
    compile.c: fix an exception argument

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 63118)
+++ compile.c	(revision 63119)
@@ -9487,6 +9487,7 @@ ibf_load_object(const struct ibf_load *l https://github.com/ruby/ruby/blob/trunk/compile.c#L9487
 	    ibf_offset_t *offsets = (ibf_offset_t *)(load->header->object_list_offset + load->buff);
 	    ibf_offset_t offset = offsets[object_index];
 	    const struct ibf_object_header *header = IBF_OBJHEADER(offset);
+	    size_t value_offset;
 
 #if IBF_ISEQ_DEBUG
 	    fprintf(stderr, "ibf_load_object: list=%#x offsets=%p offset=%#x\n",
@@ -9494,10 +9495,11 @@ ibf_load_object(const struct ibf_load *l https://github.com/ruby/ruby/blob/trunk/compile.c#L9495
 	    fprintf(stderr, "ibf_load_object: type=%#x special=%d frozen=%d internal=%d\n",
 	            header->type, header->special_const, header->frozen, header->internal);
 #endif
-	    if ((const char *)(header + 1) - load->buff >= RSTRING_LEN(load->str)) {
-		rb_raise(rb_eIndexError, "object offset out of range: %"PRIdSIZE, offset);
-            }
-	    offset = (ibf_offset_t)((const char *)(header + 1) - load->buff);
+	    value_offset = (const char *)(header + 1) - load->buff;
+	    if (value_offset >= (size_t)RSTRING_LEN(load->str)) {
+		rb_raise(rb_eIndexError, "object offset out of range: %"PRIdSIZE, value_offset);
+	    }
+	    offset = (ibf_offset_t)value_offset;
 
 	    if (header->special_const) {
 		const VALUE *vp = IBF_OBJBODY(VALUE, offset);

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

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