1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* variable.c (rb_class_path): need to adjust snprintf() len for

teminating NUL.  [ruby-dev:26581]

* error.c (syserr_initialize): don't use str before StringValue()
  check.  [ruby-dev:26579]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2005-07-20 01:08:13 +00:00
parent 81ad8ec096
commit 2201229b4a
5 changed files with 23 additions and 11 deletions

View file

@ -1,3 +1,8 @@
Wed Jul 20 10:04:51 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_class_path): need to adjust snprintf() len for
teminating NUL. [ruby-dev:26581]
Wed Jul 20 03:58:52 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/socket/socket.c: sorry, BeOS also uses HAVE_CLOSESOCKET,
@ -12,6 +17,11 @@ Wed Jul 20 03:12:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
it's defined to rb_w32_close(), otherwise handle leaks.
[ruby-Bugs-2131]
Wed Jul 20 00:48:16 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* error.c (syserr_initialize): don't use str before StringValue()
check. [ruby-dev:26579]
Tue Jul 19 22:47:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* error.c (syserr_initialize): add 1 byte for snprintf() size for

View file

@ -956,12 +956,14 @@ syserr_initialize(argc, argv, self)
else err = "unknown error";
if (!NIL_P(mesg)) {
VALUE str = mesg;
size_t len = strlen(err)+RSTRING(str)->len+3;
size_t len;
StringValue(str);
len = strlen(err)+RSTRING(str)->len+3;
mesg = rb_str_new(0, len);
snprintf(RSTRING(mesg)->ptr, len+1, "%s - %.*s", err,
(int)RSTRING(str)->len, RSTRING(str)->ptr);
rb_str_resize(mesg, strlen(RSTRING(mesg)->ptr));
RSTRING(mesg)->len = strlen(RSTRING(mesg)->ptr);
}
else {
mesg = rb_str_new2(err);

View file

@ -301,9 +301,9 @@ rb_any_to_s(obj)
size_t len;
VALUE str;
len = strlen(cname)+6+16+1;
str = rb_str_new(0, len); /* 6:tags 16:addr 1:nul */
snprintf(RSTRING(str)->ptr, len, "#<%s:0x%lx>", cname, obj);
len = strlen(cname)+6+16;
str = rb_str_new(0, len); /* 6:tags 16:addr */
snprintf(RSTRING(str)->ptr, len+1, "#<%s:0x%lx>", cname, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(obj)) OBJ_TAINT(str);
@ -389,9 +389,9 @@ rb_obj_inspect(obj)
char *c;
c = rb_obj_classname(obj);
len = strlen(c)+10+16+1;
str = rb_str_new(0, len); /* 10:tags 16:addr 1:nul */
snprintf(RSTRING(str)->ptr, len, "-<%s:0x%lx", c, obj);
len = strlen(c)+10+16;
str = rb_str_new(0, len); /* 10:tags 16:addr */
snprintf(RSTRING(str)->ptr, len+1, "-<%s:0x%lx", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return rb_exec_recursive(inspect_obj, obj, str);
}

View file

@ -477,10 +477,10 @@ inspect_struct(s, dummy, recur)
if (recur) {
char *cname = rb_class2name(rb_obj_class(s));
size_t len = strlen(cname) + 15;
size_t len = strlen(cname) + 14;
VALUE str = rb_str_new(0, len);
snprintf(RSTRING(str)->ptr, len, "#<struct %s:...>", cname);
snprintf(RSTRING(str)->ptr, len+1, "#<struct %s:...>", cname);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return str;
}

View file

@ -208,7 +208,7 @@ rb_class_path(klass)
}
len = 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1;
path = rb_str_new(0, len);
snprintf(RSTRING(path)->ptr, len, "#<%s:0x%lx>", s, klass);
snprintf(RSTRING(path)->ptr, len+1, "#<%s:0x%lx>", s, klass);
RSTRING(path)->len = strlen(RSTRING(path)->ptr);
rb_ivar_set(klass, tmp_classpath, path);