aboutsummaryrefslogtreecommitdiffstats
path: root/ext/psych/psych_parser.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:44:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:44:01 +0000
commitdfe11b5df4c8c37f07685da46eea7670dcb562be (patch)
treeebb5a982234e827223776db8b157f6b5f9b8277f /ext/psych/psych_parser.c
parenta287b53edd0a153695db628ae21c1328b5025c24 (diff)
downloadruby-dfe11b5df4c8c37f07685da46eea7670dcb562be.tar.gz
psych: allocate structs with wrapper
* ext/psych/psych_emitter.c (allocate): allocate structs with making new wrapper objects and get rid of potential memory leak. * ext/psych/psych_parser.c (allocate): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/psych_parser.c')
-rw-r--r--ext/psych/psych_parser.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c
index faae460dd0..2caa8a09c3 100644
--- a/ext/psych/psych_parser.c
+++ b/ext/psych/psych_parser.c
@@ -70,11 +70,11 @@ static const rb_data_type_t psych_parser_type = {
static VALUE allocate(VALUE klass)
{
yaml_parser_t * parser;
+ VALUE obj = TypedData_Make_Struct(klass, yaml_parser_t, &psych_parser_type, parser);
- parser = xmalloc(sizeof(yaml_parser_t));
yaml_parser_initialize(parser);
- return TypedData_Wrap_Struct(klass, &psych_parser_type, parser);
+ return obj;
}
static VALUE make_exception(yaml_parser_t * parser, VALUE path)