Skip to content

Commit

Permalink
Fix free function
Browse files Browse the repository at this point in the history
The crypt library is almost certainly using `malloc` and not `xmalloc`.
We should use `free` instead of `xfree` to ensure the malloc / free
calls are correctly balanced.
  • Loading branch information
tenderlove committed Nov 27, 2019
1 parent c396e39 commit 75d8aa0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/mri/bcrypt_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static VALUE bc_salt(VALUE self, VALUE prefix, VALUE count, VALUE input) {
if(!salt) return Qnil;

str_salt = rb_str_new2(salt);
xfree(salt);
free(salt);

return str_salt;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ static VALUE bc_crypt(VALUE self, VALUE key, VALUE setting) {

out = rb_str_new(args.data, args.size - 1);

xfree(args.data);
free(args.data);

return out;
}
Expand Down

0 comments on commit 75d8aa0

Please sign in to comment.