From 2e10fa962f8b7e93e1e208e22de75820732271c7 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 9 Apr 2003 15:27:39 +0000 Subject: * time.c (time_strftime): RSTRING(format)->ptr might become NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'time.c') diff --git a/time.c b/time.c index f956d3154b..149f8eca8c 100644 --- a/time.c +++ b/time.c @@ -1279,7 +1279,7 @@ time_strftime(time, format) if (len == 0) { rb_warning("strftime called with empty format string"); } - if (strlen(fmt) < len) { + else if (strlen(fmt) < len) { /* Ruby string may contain \0's. */ char *p = fmt, *pe = fmt + len; @@ -1297,7 +1297,9 @@ time_strftime(time, format) } return str; } - len = rb_strftime(&buf, RSTRING(format)->ptr, &tobj->tm); + else { + len = rb_strftime(&buf, RSTRING(format)->ptr, &tobj->tm); + } str = rb_str_new(buf, len); if (buf != buffer) free(buf); return str; -- cgit v1.2.3