Skip to content

Commit

Permalink
fix: free codepoints before returning to prevent memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytonyjan committed Sep 30, 2017
1 parent 20865f4 commit 8babd4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/jaro_winkler/jaro_winkler.c
Expand Up @@ -54,8 +54,11 @@ VALUE distance(size_t argc, VALUE *argv, VALUE self,
c_opt.adj_table =
(TYPE(adj_table) == T_FALSE || NIL_P(adj_table)) ? 0 : 1;
}
return rb_float_new(
VALUE ret = rb_float_new(
(*distance_fn)(cp1.data, cp1.length, cp2.data, cp2.length, &c_opt));
codepoints_free(&cp1);
codepoints_free(&cp2);
return ret;
}

VALUE rb_jaro_distance(size_t argc, VALUE *argv, VALUE self) {
Expand Down

0 comments on commit 8babd4f

Please sign in to comment.