From afd7aea8577988d77cd7faed3524a92f29640e2b Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 28 Dec 2004 13:32:28 +0000 Subject: [PATCH] * string.c (rb_str_justify): create buffer string after argument type conversion. fixed: [ruby-dev:25341] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fdba29a885..7645fc64d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Dec 28 22:31:46 2004 Nobuyoshi Nakada + + * string.c (rb_str_justify): create buffer string after argument type + conversion. fixed: [ruby-dev:25341] + Tue Dec 28 17:18:17 2004 NAKAMURA Usaku * lib/net/telnet.rb (preprocess): remove NULL unless binmode. diff --git a/string.c b/string.c index b566e7159f..73742cc38f 100644 --- a/string.c +++ b/string.c @@ -4505,7 +4505,6 @@ rb_str_justify(argc, argv, str, jflag) rb_scan_args(argc, argv, "11", &w, &pad); width = NUM2LONG(w); if (width < 0 || RSTRING(str)->len >= width) return rb_str_dup(str); - res = rb_str_new5(str, 0, width); if (argc == 2) { StringValue(pad); f = RSTRING(pad)->ptr; @@ -4514,6 +4513,7 @@ rb_str_justify(argc, argv, str, jflag) rb_raise(rb_eArgError, "zero width padding"); } } + res = rb_str_new5(str, 0, width); p = RSTRING(res)->ptr; if (jflag != 'l') { n = width - RSTRING(str)->len;