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

ruby-changes:4303

From: ko1@a...
Date: Tue, 18 Mar 2008 16:25:20 +0900 (JST)
Subject: [ruby-changes:4303] nobu - Ruby:r15793 (trunk): * parse.y (literal_concat_gen): bail out at different encoding.

nobu	2008-03-18 16:24:55 +0900 (Tue, 18 Mar 2008)

  New Revision: 15793

  Modified files:
    trunk/ChangeLog
    trunk/parse.y

  Log:
    * parse.y (literal_concat_gen): bail out at different encoding.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=15793&r2=15792&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15793&r2=15792&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15792)
+++ ChangeLog	(revision 15793)
@@ -1,3 +1,7 @@
+Tue Mar 18 16:24:53 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (literal_concat_gen): bail out at different encoding.
+
 Tue Mar 18 04:00:27 2008  NARUSE, Yui  <naruse@r...>
 
 	* re.c (rb_memsearch_ss): simple shift search.
Index: parse.y
===================================================================
--- parse.y	(revision 15792)
+++ parse.y	(revision 15793)
@@ -7465,15 +7465,19 @@
     return head;
 }
 
-static void
+static int
 literal_concat0(struct parser_params *parser, VALUE head, VALUE tail)
 {
     if (!rb_enc_compatible(head, tail)) {
 	compile_error(PARSER_ARG "string literal encodings differ (%s / %s)",
 		      rb_enc_name(rb_enc_get(head)),
 		      rb_enc_name(rb_enc_get(tail)));
+	rb_str_resize(head, 0);
+	rb_str_resize(tail, 0);
+	return 0;
     }
     rb_str_buf_append(head, tail);
+    return 1;
 }
 
 /* concat two string literals */
@@ -7493,7 +7497,12 @@
     switch (nd_type(tail)) {
       case NODE_STR:
 	if (htype == NODE_STR) {
-	    literal_concat0(parser, head->nd_lit, tail->nd_lit);
+	    if (!literal_concat0(parser, head->nd_lit, tail->nd_lit)) {
+	      error:
+		rb_gc_force_recycle((VALUE)head);
+		rb_gc_force_recycle((VALUE)tail);
+		return 0;
+	    }
 	    rb_gc_force_recycle((VALUE)tail);
 	}
 	else {
@@ -7503,7 +7512,8 @@
 
       case NODE_DSTR:
 	if (htype == NODE_STR) {
-	    literal_concat0(parser, head->nd_lit, tail->nd_lit);
+	    if (!literal_concat0(parser, head->nd_lit, tail->nd_lit))
+		goto error;
 	    tail->nd_lit = head->nd_lit;
 	    rb_gc_force_recycle((VALUE)head);
 	    head = tail;

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

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