Skip to content
Permalink
Browse files
Fix segmentation fault ref: #3648
  • Loading branch information
ksss committed May 8, 2017
1 parent ef30530 commit 30df7c87624692227a24eee7ed7c2507b249e6e5
Showing 2 changed files with 14 additions and 8 deletions.
@@ -982,15 +982,17 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
}
if (dots) PUSH("..", 2);

if (v < 0) {
char c = sign_bits(base, p);
FILL(c, prec - len);
}
else if ((flags & (FMINUS|FPREC)) != FMINUS) {
char c = '0';
FILL(c, prec - len);
if (prec > len) {
CHECK(prec - len);
if (v < 0) {
char c = sign_bits(base, p);
FILL(c, prec - len);
}
else if ((flags & (FMINUS|FPREC)) != FMINUS) {
char c = '0';
FILL(c, prec - len);
}
}

PUSH(s, len);
if (width > 0) {
FILL(' ', width);
@@ -87,6 +87,10 @@ class Fixnum
end
end

assert("String#% %b") do
assert_equal("..10115", "%0b5" % -5)
end

assert("String#% invalid format") do
assert_raise ArgumentError do
"%?" % ""

0 comments on commit 30df7c8

Please sign in to comment.