9 Commits
Author SHA1 Message Date
Kevin Newton e80cd771b3 [ruby/prism] Define PRISM_OOM
So we have a centralized place to handle out of memory errors.

https://github.com/ruby/prism/commit/14969912cc
2026-10-28 05:56:30 +00:00
Kevin Newton caf4f279d1 [ruby/prism] Test embedded in CI
Make sure we do not accidentally break newlib/ARM embedded consumers.

https://github.com/ruby/prism/commit/19762c99ce
2026-10-27 14:17:54 +00:00
HASUMI Hitoshi ab52c6ab86 [ruby/prism] Include sys/types.h before inttypes.h again, for newlib
61ebe5123 made defines.h include <sys/types.h> ahead of <inttypes.h>:
with an arm-none-eabi toolchain whose <stdint.h> is GCC's own, newlib's
<inttypes.h> never sees the marker it tests before defining the 64-bit
PRI macros, and PRIu64 goes undefined while PRIu32 does not. 400b21739
("Remove defines") took the header out and the workaround with it, so
a cross build of integer.c and errors_format.c, the two files that
include <inttypes.h> now, fails on such a toolchain (Debian's
gcc-arm-none-eabi 13.2.1 with newlib). Put the include back in those
two files, with the note.

https://github.com/ruby/prism/commit/ff42521e49
2026-10-26 15:43:58 +00:00
Yukihiro Matsumoto 395f8b920a [ruby/prism] Bound the leading-zero skip in pm_integer_parse
The PM_INTEGER_BASE_DEFAULT branch skips leading zeros without checking
`end`, so it reads one byte past the range for an all-zero input.

pm_float_node_rational_create() reaches it: it allocates `length` bytes
for the mantissa, writes only `length - 1` of them because the decimal
point is squeezed out, and passes end = digits + length - 1. Parsing
`+0.0r` then walks the skip onto the byte that was never written.

    $ valgrind ./parse +0.0r
    Conditional jump or move depends on uninitialised value(s)
       at pm_integer_parse (integer.c:506)
       by pm_float_node_rational_create (prism.c:3963)
       by parse_expression_prefix (prism.c:17898)

The value parsed is unaffected, since `start >= end` returns 0 either
way. The other bases already guard with `(end - start) > 1`.

Found by an mruby fuzzer testcase.

https://github.com/ruby/prism/commit/f9629ee735
2026-08-01 11:40:57 +00:00
Kevin Newton 401bf504ba [ruby/prism] Revert xfree_sized for integer
https://github.com/ruby/prism/commit/eb398af793
2026-03-20 09:37:43 -04:00
Kevin Newton 2e103d7be9 [ruby/prism] Use xfree_sized everywhere possible
https://github.com/ruby/prism/commit/603e482c10
2026-03-20 09:37:43 -04:00
Kevin Newton 096b3e032d [ruby/prism] Move allocator to internal headers
https://github.com/ruby/prism/commit/1e3ec12adc
2026-03-20 09:37:43 -04:00
Kevin Newton 6995c9def3 [ruby/prism] Split up integer between public and private headers
https://github.com/ruby/prism/commit/16fd2bf08a
2026-03-20 09:37:43 -04:00
Kevin Newton 640d4173bb [ruby/prism] Move integer out of utils
https://github.com/ruby/prism/commit/cdc9b97f4d
2026-03-20 09:37:43 -04:00