Skip to content

Commit

Permalink
Prefer Fixnums to Numerics
Browse files Browse the repository at this point in the history
Numerics are effectively integers and floats in Ruby, whereas Fixnums
are effectively just integers. Let's use slightly tighter bounds on our
types to catch any potential weird type errors sooner.
  • Loading branch information
mschwager committed Feb 6, 2024
1 parent 9b04b6e commit 9c80b2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/cruzzy/cruzzy.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int proc_caller(const uint8_t *data, size_t size)
);
}

return NUM2INT(result);
return FIX2INT(result);
}

static VALUE c_fuzz(VALUE self, VALUE test_one_input, VALUE args)
Expand Down Expand Up @@ -120,7 +120,7 @@ static VALUE c_fuzz(VALUE self, VALUE test_one_input, VALUE args)
// https://llvm.org/docs/LibFuzzer.html#using-libfuzzer-as-a-library
int result = LLVMFuzzerRunDriver(&args_len, &args_ptr, proc_caller);

return INT2NUM(result);
return INT2FIX(result);
}

void Init_cruzzy()
Expand Down

0 comments on commit 9c80b2e

Please sign in to comment.