* error.c (syserr_initialize): add 1 byte for snprintf() size for
NUL at the end. [ruby-dev:26574] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
30434d4078
commit
7af1a11438
@ -1,7 +1,7 @@
|
|||||||
Tue Jul 19 22:47:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Jul 19 22:47:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* error.c (syserr_initialize): need to allocate an additional byte
|
* error.c (syserr_initialize): add 1 byte for snprintf() size for
|
||||||
for NUL at the end. [ruby-dev:26574]
|
NUL at the end. [ruby-dev:26574]
|
||||||
|
|
||||||
Tue Jul 19 17:16:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Jul 19 17:16:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
4
error.c
4
error.c
@ -956,10 +956,10 @@ syserr_initialize(argc, argv, self)
|
|||||||
else err = "unknown error";
|
else err = "unknown error";
|
||||||
if (!NIL_P(mesg)) {
|
if (!NIL_P(mesg)) {
|
||||||
VALUE str = mesg;
|
VALUE str = mesg;
|
||||||
size_t len = strlen(err)+RSTRING(str)->len+4;
|
size_t len = strlen(err)+RSTRING(str)->len+3;
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
mesg = rb_str_new(0, len);
|
mesg = rb_str_new(0, len);
|
||||||
snprintf(RSTRING(mesg)->ptr, len, "%s - %.*s", err,
|
snprintf(RSTRING(mesg)->ptr, len+1, "%s - %.*s", err,
|
||||||
(int)RSTRING(str)->len, RSTRING(str)->ptr);
|
(int)RSTRING(str)->len, RSTRING(str)->ptr);
|
||||||
rb_str_resize(mesg, strlen(RSTRING(mesg)->ptr));
|
rb_str_resize(mesg, strlen(RSTRING(mesg)->ptr));
|
||||||
}
|
}
|
||||||
|
6
eval.c
6
eval.c
@ -8667,20 +8667,20 @@ proc_to_s(self)
|
|||||||
NODE *node;
|
NODE *node;
|
||||||
char *cname = rb_obj_classname(self);
|
char *cname = rb_obj_classname(self);
|
||||||
const int w = (SIZEOF_LONG * CHAR_BIT) / 4;
|
const int w = (SIZEOF_LONG * CHAR_BIT) / 4;
|
||||||
long len = strlen(cname)+6+w+1; /* 6:tags 16:addr NUL */
|
long len = strlen(cname)+6+w; /* 6:tags 16:addr */
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
|
||||||
Data_Get_Struct(self, struct BLOCK, data);
|
Data_Get_Struct(self, struct BLOCK, data);
|
||||||
if ((node = data->frame.node) || (node = data->body)) {
|
if ((node = data->frame.node) || (node = data->body)) {
|
||||||
len += strlen(node->nd_file) + 2 + (SIZEOF_LONG*CHAR_BIT-NODE_LSHIFT)/3;
|
len += strlen(node->nd_file) + 2 + (SIZEOF_LONG*CHAR_BIT-NODE_LSHIFT)/3;
|
||||||
str = rb_str_new(0, len);
|
str = rb_str_new(0, len);
|
||||||
snprintf(RSTRING(str)->ptr, len,
|
snprintf(RSTRING(str)->ptr, len+1,
|
||||||
"#<%s:0x%.*lx@%s:%d>", cname, w, (VALUE)data->body,
|
"#<%s:0x%.*lx@%s:%d>", cname, w, (VALUE)data->body,
|
||||||
node->nd_file, nd_line(node));
|
node->nd_file, nd_line(node));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str = rb_str_new(0, len);
|
str = rb_str_new(0, len);
|
||||||
snprintf(RSTRING(str)->ptr, len,
|
snprintf(RSTRING(str)->ptr, len+1,
|
||||||
"#<%s:0x%.*lx>", cname, w, (VALUE)data->body);
|
"#<%s:0x%.*lx>", cname, w, (VALUE)data->body);
|
||||||
}
|
}
|
||||||
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
|
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user