summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@gmail.com>2023-09-13 15:55:36 -0400
committergit <svn-admin@ruby-lang.org>2023-09-13 21:26:44 +0000
commit3d453bc672863e437c47caab47d0db5aab6e8629 (patch)
tree38a2eb7f1cf7ca54a481e820241a88a77468e5d9
parentb49be2a70fd715b15f69dae776ba37d9b8d3a3fb (diff)
[ruby/yarp] free strings in the ruby extension
https://github.com/ruby/yarp/commit/87dbb6cf1f
-rw-r--r--yarp/extension.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/yarp/extension.c b/yarp/extension.c
index 8d36cd4427..f951b0c4a7 100644
--- a/yarp/extension.c
+++ b/yarp/extension.c
@@ -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.
@@ -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;
}
@@ -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;
}