diff options
author | Florian Frank <flori@ping.de> | 2015-05-29 17:12:52 +0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2015-05-29 17:12:52 +0200 |
commit | d4c99de78905d96c3f301f48b2c789943bb3f098 (patch) | |
tree | 82ddecaa902579a5f56b2c8f5d00e1399df5c5f3 /ext/json/ext/parser/parser.c | |
parent | 638a1f782a5539281df39969d817cd7b55dd53f5 (diff) | |
parent | fae344f2f12a73baf0d4afa663eee3d942aeec8e (diff) | |
download | json-d4c99de78905d96c3f301f48b2c789943bb3f098.tar.gz |
Merge pull request #247 from nobu/potential_memory_leak
Potential memory leak
Diffstat (limited to 'ext/json/ext/parser/parser.c')
-rw-r--r-- | ext/json/ext/parser/parser.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index eed58e5..9c9d76a 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -2091,14 +2091,6 @@ static VALUE cParser_parse(VALUE self) } } - -static JSON_Parser *JSON_allocate(void) -{ - JSON_Parser *json = ZALLOC(JSON_Parser); - json->fbuffer = fbuffer_alloc(0); - return json; -} - static void JSON_mark(void *ptr) { JSON_Parser *json = ptr; @@ -2135,8 +2127,10 @@ static const rb_data_type_t JSON_Parser_type = { static VALUE cJSON_parser_s_allocate(VALUE klass) { - JSON_Parser *json = JSON_allocate(); - return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json); + JSON_Parser *json; + VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json); + json->fbuffer = fbuffer_alloc(0); + return obj; } /* |