Skip to content

Commit b8db23a

Browse files
committed
merge revision(s) r46569: [Backport ruby#9982]
* sprintf.c (GETASTER): should not use the numbered argument to be formatted, raise ArgumentError instead. [ruby-dev:48330] [Bug ruby#9982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9e95cee commit b8db23a

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Thu Sep 4 00:23:15 2014 Nobuyoshi Nakada <[email protected]>
2+
3+
* sprintf.c (GETASTER): should not use the numbered argument to be
4+
formatted, raise ArgumentError instead.
5+
[ruby-dev:48330] [Bug #9982]
6+
17
Thu Sep 4 00:21:05 2014 SHIBATA Hiroshi <[email protected]>
28

39
* test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak):

sprintf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ sign_bits(int base, const char *p)
7979
} while (0)
8080

8181
#define GETARG() (nextvalue != Qundef ? nextvalue : \
82+
GETNEXTARG())
83+
84+
#define GETNEXTARG() ( \
8285
posarg == -1 ? \
8386
(rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
8487
posarg == -2 ? \
@@ -125,7 +128,7 @@ sign_bits(int base, const char *p)
125128
tmp = GETPOSARG(n); \
126129
} \
127130
else { \
128-
tmp = GETARG(); \
131+
tmp = GETNEXTARG(); \
129132
p = t; \
130133
} \
131134
(val) = NUM2INT(tmp); \

test/ruby/test_sprintf.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ def test_invalid
179179
assert_raise(ArgumentError) { sprintf("%!", 1) }
180180
assert_raise(ArgumentError) { sprintf("%1$1$d", 1) }
181181
assert_raise(ArgumentError) { sprintf("%0%") }
182+
183+
assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$*d", 3) }
184+
assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$.*d", 3) }
185+
182186
verbose, $VERBOSE = $VERBOSE, nil
183187
assert_nothing_raised { sprintf("", 1) }
184188
ensure

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.2"
22
#define RUBY_RELEASE_DATE "2014-09-04"
3-
#define RUBY_PATCHLEVEL 219
3+
#define RUBY_PATCHLEVEL 220
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 9

0 commit comments

Comments
 (0)