Skip to content

Commit

Permalink
Fixing a rare bug when calling BCrypt::Engine#hash_secret - which pro…
Browse files Browse the repository at this point in the history
…duces nil accidentally 1 out of 500 cases in TruffleRuby.

Co-authored-by: Benoit Daloze <benoit.daloze@oracle.com>
Co-authored-by: Peter Arato <it.arato@gmail.com>
  • Loading branch information
itarato and eregon committed Jun 22, 2023
1 parent e402d69 commit 53ec1e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/mri/bcrypt_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ static VALUE bc_salt(VALUE self, VALUE prefix, VALUE count, VALUE input) {
if(!salt) return Qnil;

str_salt = rb_str_new2(salt);

RB_GC_GUARD(prefix);
RB_GC_GUARD(input);
free(salt);

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

out = rb_str_new2(value);

RB_GC_GUARD(key);
RB_GC_GUARD(setting);
free(args.data);

return out;
Expand Down

0 comments on commit 53ec1e1

Please sign in to comment.