Skip to content

Commit

Permalink
free some string after use.
Browse files Browse the repository at this point in the history
  • Loading branch information
Z572 committed Sep 12, 2023
1 parent c7b1756 commit 2ad6d58
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions ts/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ SCM_DEFINE(tsp_parse_string, "ts-parser-parse-string", 3, 1, 0,
ts_parser_parse_string(FR(p), (scm_is_true(tree)) ? (FR(tree)) : NULL,
cstring,
clength);
free(cstring);
SCM s_tst=tst ? make_foreign_object(tst_type, tst) : SCM_BOOL_F;
scm_remember_upto_here_2(p,tree);
return s_tst;
Expand Down
1 change: 1 addition & 0 deletions ts/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SCM_DEFINE(query_new, "ts-query-new", 2,0, 0,
c_length,
&error_offset,
&error_type);
free(c_string);
SCM fo= query ? make_foreign_object(query_type, query) : SCM_BOOL_F;
return query
? scm_values_3(fo, SCM_BOOL_F,SCM_BOOL_F)
Expand Down
4 changes: 3 additions & 1 deletion ts/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@ SCM_DEFINE(tsn_child_by_field_name, "ts-node-child-by-field-name", 2, 1, 0,
SCM_ASSERT((scm_c_string_length(name) < scm_to_uint32(length)), length, SCM_ARG3, FUNC_NAME);
}
Node *node=FR(o);
char* c_string=scm_to_utf8_string(name);
SCM sn=make_node(ts_node_child_by_field_name
(node_ref(node),
scm_to_utf8_string(name),
c_string,
SCM_UNBNDP(length)
? scm_c_string_length(name)
: scm_to_uint32(length)));
free(c_string);
scm_remember_upto_here_2(o,name);
scm_remember_upto_here_1(length);
return sn;
Expand Down

0 comments on commit 2ad6d58

Please sign in to comment.