Skip to content

Commit 5a5550d

Browse files
authored
Merge pull request ruby#3533 from Shopify/use-xalloc
2 parents 6ae402e + bd9027f commit 5a5550d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/prism.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4253,7 +4253,7 @@ pm_float_node_rational_create(pm_parser_t *parser, const pm_token_t *token) {
42534253
const uint8_t *point = memchr(start, '.', length);
42544254
assert(point && "should have a decimal point");
42554255

4256-
uint8_t *digits = malloc(length);
4256+
uint8_t *digits = xmalloc(length);
42574257
if (digits == NULL) {
42584258
fputs("[pm_float_node_rational_create] Failed to allocate memory", stderr);
42594259
abort();
@@ -4266,7 +4266,7 @@ pm_float_node_rational_create(pm_parser_t *parser, const pm_token_t *token) {
42664266
digits[0] = '1';
42674267
if (end - point > 1) memset(digits + 1, '0', (size_t) (end - point - 1));
42684268
pm_integer_parse(&node->denominator, PM_INTEGER_BASE_DEFAULT, digits, digits + (end - point));
4269-
free(digits);
4269+
xfree(digits);
42704270

42714271
pm_integers_reduce(&node->numerator, &node->denominator);
42724272
return node;

0 commit comments

Comments
 (0)