Skip to content
Browse files

#sprintf: don't try to mutate symbols

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4478 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 75f2ab2 commit d6e38f5bbcc94ff1fdc04e201d68fa22e9d0f6b7 Laurent Sansonetti committed
Showing with 5 additions and 0 deletions.
  1. +5 −0 sprintf.c
View
5 sprintf.c
@@ -794,6 +794,11 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
tainted = true;
}
+ if (TYPE(arg) == T_SYMBOL) {
+ // Because symbols are not mutable and pad_format_value()
+ // mutates its first argument.
+ arg = rb_sym_to_s(arg);
+ }
pad_format_value(arg, minus_flag ? -1 : 0, width, rb_str_new2(" "));
num = cstr_update(&format_str, &format_str_capa, start,
i - start + 1, arg);

0 comments on commit d6e38f5

Please sign in to comment.
Something went wrong with that request. Please try again.