aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'error.c')
-rw-r--r--error.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/error.c b/error.c
index f35dc2ba3e..48cb00da38 100644
--- a/error.c
+++ b/error.c
@@ -956,14 +956,10 @@ syserr_initialize(argc, argv, self)
else err = "unknown error";
if (!NIL_P(mesg)) {
VALUE str = mesg;
- 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);
- RSTRING(mesg)->len = strlen(RSTRING(mesg)->ptr);
+ mesg = rb_sprintf("%s - %.*s", err,
+ (int)RSTRING(str)->len, RSTRING(str)->ptr);
}
else {
mesg = rb_str_new2(err);