Skip to content

Commit

Permalink
[ruby/yarp] free strings in the ruby extension
Browse files Browse the repository at this point in the history
  • Loading branch information
froydnj authored and matzbot committed Sep 13, 2023
1 parent b49be2a commit 3d453bc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion yarp/extension.c
Expand Up @@ -413,7 +413,11 @@ parse_lex(int argc, VALUE *argv, VALUE self) {

yp_string_t input;
input_load_string(&input, string);
return parse_lex_input(&input, check_string(filepath), true);

VALUE value = parse_lex_input(&input, check_string(filepath), true);
yp_string_free(&input);

return value;
}

// Parse and lex the given file and return a ParseResult instance.
Expand Down Expand Up @@ -530,6 +534,8 @@ profile_file(VALUE self, VALUE filepath) {
yp_node_destroy(&parser, node);
yp_parser_free(&parser);

yp_string_free(&input);

return Qnil;
}

Expand All @@ -547,6 +553,7 @@ parse_serialize_file_metadata(VALUE self, VALUE filepath, VALUE metadata) {
yp_parse_serialize(yp_string_source(&input), yp_string_length(&input), &buffer, check_string(metadata));
VALUE result = rb_str_new(yp_buffer_value(&buffer), yp_buffer_length(&buffer));

yp_string_free(&input);
yp_buffer_free(&buffer);
return result;
}
Expand Down

0 comments on commit 3d453bc

Please sign in to comment.