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;