summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sprintf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index 9770a00008..4549791d20 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -707,8 +707,12 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
VALUE arg = GETARG();
long len, slen;
- if (*p == 'p') arg = rb_inspect(arg);
- str = rb_obj_as_string(arg);
+ if (*p == 'p') {
+ str = rb_inspect(arg);
+ }
+ else {
+ str = rb_obj_as_string(arg);
+ }
if (OBJ_TAINTED(str)) tainted = 1;
len = RSTRING_LEN(str);
rb_str_set_len(result, blen);