diff --git a/ChangeLog b/ChangeLog index 62275a0408..3d55b79cbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Apr 10 00:27:07 2003 Nobuyoshi Nakada + + * time.c (time_strftime): RSTRING(format)->ptr might become NULL. + Wed Apr 9 23:54:50 2003 Yukihiro Matsumoto * variable.c (rb_obj_remove_instance_variable): better message. 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;