diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-18 07:24:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-18 07:24:55 +0000 |
commit | 91a761b4d0929a5055945ccca4797ff57353cac0 (patch) | |
tree | cd93e0bcdc75858ed88a62f8b4fcc355b33fc67a /parse.y | |
parent | e58adeae0f384a562bbcb295b0a25026842625ca (diff) |
* parse.y (literal_concat_gen): bail out at different encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -7465,15 +7465,19 @@ list_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) 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 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) 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 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) 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; |