hexyl icon indicating copy to clipboard operation
hexyl copied to clipboard

memory allocation of 4340410370284600376 bytes failed

Open Jiehong opened this issue 9 months ago • 3 comments

Hello,

A typo lead to a bug discovery:

hexyl --terminal-width 2 1.txt
memory allocation of 4340410370284600376 bytes failed

It seems any terminal width less than 10 leads to a memory allocation issue.

Jiehong avatar Apr 05 '25 12:04 Jiehong

Thank you for reporting this

sharkdp avatar Apr 05 '25 20:04 sharkdp

How large is the 1.txt file?

This should work: wc -c 1.txt

I think this has to do with the (terminal_width - offset) calculation (taking a quick peek at main).

selfup avatar Apr 07 '25 01:04 selfup

You can reproduce it with

▶ hexyl --terminal-width 2 <(echo "test")
memory allocation of 4340410370284600376 bytes failed

Looks very much just like an underflow in that subtraction, yes.

sharkdp avatar Apr 07 '25 06:04 sharkdp