summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-11 13:31:23 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-11 13:31:23 (GMT)
commitdb5265a82c221887faf0dfd0d04e47cf11a08e3a (patch)
treea8d54a47508d0e890f102faa4705ce73562f0941 /sprintf.c
parenta5d1da5d74560c812acb8db6242e389d2f27e368 (diff)
* 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.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index b9e40f4..5927c25 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -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);
}