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

ruby-changes:40899

From: ko1 <ko1@a...>
Date: Wed, 9 Dec 2015 02:20:10 +0900 (JST)
Subject: [ruby-changes:40899] ko1:r52978 (trunk): * compile.c (ibf_dump_memsize): should check NULL.

ko1	2015-12-09 02:19:58 +0900 (Wed, 09 Dec 2015)

  New Revision: 52978

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

  Log:
    * compile.c (ibf_dump_memsize): should check NULL.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52977)
+++ ChangeLog	(revision 52978)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec  9 02:18:52 2015  Koichi Sasada  <ko1@a...>
+
+	* compile.c (ibf_dump_memsize): should check NULL.
+
 Wed Dec  9 01:46:35 2015  NAKAMURA Usaku  <usa@r...>
 
 	* string.c (rb_str_init): now accepts new option parameter `encoding'.
Index: compile.c
===================================================================
--- compile.c	(revision 52977)
+++ compile.c	(revision 52978)
@@ -8054,11 +8054,16 @@ ibf_dump_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/compile.c#L8054
 static size_t
 ibf_dump_memsize(const void *ptr)
 {
-    struct ibf_dump *dump = (struct ibf_dump *)ptr;
-    size_t size = sizeof(*dump);
-    if (dump->iseq_table) size += st_memsize(dump->iseq_table);
-    if (dump->id_table) size += st_memsize(dump->id_table);
-    return size;
+    if (ptr) {
+	struct ibf_dump *dump = (struct ibf_dump *)ptr;
+	size_t size = sizeof(*dump);
+	if (dump->iseq_table) size += st_memsize(dump->iseq_table);
+	if (dump->id_table) size += st_memsize(dump->id_table);
+	return size;
+    }
+    else {
+	return 0;
+    }
 }
 
 static const rb_data_type_t ibf_dump_type = {

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

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