aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 12:56:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 12:56:29 +0000
commitcb54008be67547866fa7a552a3eff5059d34c1b3 (patch)
tree382100cd92c8fe645edae9c8e0fba362230a737a /error.c
parent5ffb21ebbd37bbb71b9c6f25c9c621cb3f037a1b (diff)
downloadruby-cb54008be67547866fa7a552a3eff5059d34c1b3.tar.gz
wrapper object before alloc
* error.c (rb_name_err_mesg_new): new wrapper object before allocate data area and get rid of potential memory leak. GC guards are no longer needed. * file.c (stat_new_0): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/error.c b/error.c
index bb7cb1c4af..07b04a1036 100644
--- a/error.c
+++ b/error.c
@@ -1155,16 +1155,13 @@ static const rb_data_type_t name_err_mesg_data_type = {
VALUE
rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method)
{
+ VALUE result = TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, 0);
VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT);
- VALUE result;
ptr[0] = mesg;
ptr[1] = recv;
ptr[2] = method;
- result = TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, ptr);
- RB_GC_GUARD(mesg);
- RB_GC_GUARD(recv);
- RB_GC_GUARD(method);
+ RTYPEDDATA_DATA(result) = ptr;
return result;
}