diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-11 13:31:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-11 13:31:23 +0000 |
commit | db5265a82c221887faf0dfd0d04e47cf11a08e3a (patch) | |
tree | a8d54a47508d0e890f102faa4705ce73562f0941 /sprintf.c | |
parent | a5d1da5d74560c812acb8db6242e389d2f27e368 (diff) | |
download | ruby-db5265a82c221887faf0dfd0d04e47cf11a08e3a.tar.gz |
* parse.y (rb_check_id_cstr): new function to check if ID is
registered with NUL-terminated C string.
* sprintf.c (rb_str_format): avoid inadvertent symbol creation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -588,8 +588,11 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) rb_enc_raise(enc, rb_eArgError, "named%.*s after <%s>", len, start, rb_id2name(id)); } - id = rb_intern3(start + 1, len - 2 /* without parenthesis */, enc); - nextvalue = GETNAMEARG(ID2SYM(id), start, len, enc); + nextvalue = GETNAMEARG((id = rb_check_id_cstr(start + 1, + len - 2 /* without parenthesis */, + enc), + ID2SYM(id)), + start, len, enc); if (nextvalue == Qundef) { rb_enc_raise(enc, rb_eKeyError, "key%.*s not found", len, start); } |