From 51e0cceb41b1371a7beef6c407d40e3d54a5f0fa Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 21 Nov 2005 13:52:49 +0000 Subject: * parse.y (dsym): prohibit empty symbol literal by interpolation. fixed: [ruby-talk:166529] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index dc56a4fe2..e9193c7fd 100644 --- a/parse.y +++ b/parse.y @@ -3864,12 +3864,19 @@ dsym : tSYMBEG xstring_contents tSTRING_END yyerror("empty symbol literal"); } else { + VALUE lit; + switch (nd_type($$)) { case NODE_DSTR: nd_set_type($$, NODE_DSYM); break; case NODE_STR: - if (strlen(RSTRING($$->nd_lit)->ptr) == RSTRING($$->nd_lit)->len) { + lit = $$->nd_lit; + if (RSTRING(lit)->len == 0) { + yyerror("empty symbol literal"); + break; + } + if (strlen(RSTRING(lit)->ptr) == RSTRING(lit)->len) { $$->nd_lit = ID2SYM(rb_intern(RSTRING($$->nd_lit)->ptr)); nd_set_type($$, NODE_LIT); break; -- cgit