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

ruby-changes:43407

From: nobu <ko1@a...>
Date: Tue, 21 Jun 2016 16:38:22 +0900 (JST)
Subject: [ruby-changes:43407] nobu:r55481 (trunk): Fix garbage allocation

nobu	2016-06-21 16:38:16 +0900 (Tue, 21 Jun 2016)

  New Revision: 55481

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

  Log:
    Fix garbage allocation
    
    * string.c (rb_str_casemap): do not put code with side effects
      inside RSTRING_PTR() macro which evaluates the argument multiple
      times.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 55480)
+++ string.c	(revision 55481)
@@ -5811,12 +5811,14 @@ rb_str_casemap(VALUE source, OnigCaseFol https://github.com/ruby/ruby/blob/trunk/string.c#L5811
 
     if (buffer_count==1) {
 	target = rb_str_new_with_class(source, (const char*)current_buffer->space, target_length);
-	    xfree(current_buffer);
+	xfree(current_buffer);
     }
     else {
-	char *target_current = RSTRING_PTR(target = rb_str_new_with_class(source, 0, target_length));
+	char *target_current;
 	mapping_buffer *previous_buffer;
 
+	target = rb_str_new_with_class(source, 0, target_length);
+	target_current = RSTRING_PTR(target);
 	current_buffer=pre_buffer.next;
 	while (current_buffer) {
 	    memcpy(target_current, current_buffer->space, current_buffer->used);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55480)
+++ ChangeLog	(revision 55481)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jun 21 16:38:14 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_casemap): do not put code with side effects
+	  inside RSTRING_PTR() macro which evaluates the argument multiple
+	  times.
+
 Tue Jun 21 16:13:45 2016  NARUSE, Yui  <naruse@r...>
 
 	* string.c (rb_str_casemap): fix memory leak.

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

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