aboutsummaryrefslogtreecommitdiffstats
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 11:46:44 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 11:46:44 +0000
commita97af1c6aa2a8cb0be79ceb9c4b51acf3b70bbaa (patch)
treeaef0672833fa7ffa9be3163f246195446ba5b88e /sprintf.c
parent90ba0eac46b92f0249992fa056877d1b6e55d063 (diff)
downloadruby-a97af1c6aa2a8cb0be79ceb9c4b51acf3b70bbaa.tar.gz
* sprintf.c (rb_str_format): a bug in %c type check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sprintf.c b/sprintf.c
index 953ce5054c..4c5e56843c 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -399,13 +399,15 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
case 'c':
{
VALUE val = GETARG();
+ VALUE tmp;
char c;
- if (rb_check_string_type(val)) {
- if (RSTRING(val)->len != 1) {
+ tmp = rb_check_string_type(val);
+ if (!NIL_P(tmp)) {
+ if (RSTRING(tmp)->len != 1) {
rb_raise(rb_eArgError, "%%c requires a character");
}
- c = RSTRING(val)->ptr[0];
+ c = RSTRING(tmp)->ptr[0];
}
else {
c = NUM2INT(val) & 0xff;