mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
90ba0eac46
commit
a97af1c6aa
2 changed files with 9 additions and 3 deletions
|
@ -14,6 +14,10 @@ Fri Aug 4 13:56:51 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* pack.c (pack_pack): check argument overrun for 'P'. based on a
|
||||
patch by rucila <rucila at yahoo.cojp>. fixed: [ruby-dev:29182]
|
||||
|
||||
Fri Aug 4 02:42:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* sprintf.c (rb_str_format): a bug in %c type check.
|
||||
|
||||
Fri Aug 4 01:28:19 2006 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (io_reopen): STDERR.reopen(File.open("/dev/null", "w")) should
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue