-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I tried to load a really big .png (32768x32768 or even 65536x65536) which unfortunately crashed.
When stripping the code fragment down I realized that writing seems to work, but reading crashes roundabout at 0x2d60 size.
# https://crystalshards.org/shards/github/stumpycr/stumpy_png
require "stumpy_png"
include StumpyPNG
SIZE = 0x2d60 # 0x2d40 works, 0x2d60 breaks
canvas = Canvas.new(SIZE, SIZE)
StumpyPNG.write(canvas, "foo.png") # still works
canvas = StumpyPNG.read("foo.png") # raises below exception
# triggers:
# Unhandled exception: Arithmetic overflow (OverflowError)
# from /snap/crystal/1064/share/crystal/src/math/math.cr:738:7 in 'pw2ceil'
# from /snap/crystal/1064/share/crystal/src/io/memory.cr:96:26 in 'write'
# from /snap/crystal/1064/share/crystal/src/io.cr:1144:7 in 'copy'
# from lib/stumpy_png/src/stumpy_png/png.cr:57:9 in 'parse_IEND'
# from lib/stumpy_png/src/stumpy_png/png.cr:219:20 in 'parse_chunk'
# from lib/stumpy_png/src/stumpy_png.cr:31:7 in 'read'
# from lib/stumpy_png/src/stumpy_png.cr:23:7 in 'read'
# from src/merger.cr:11:1 in '__crystal_main'
# from /snap/crystal/1064/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
# from /snap/crystal/1064/share/crystal/src/crystal/main.cr:101:7 in 'main'
# from /snap/crystal/1064/share/crystal/src/crystal/main.cr:127:3 in 'main'
# from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
# from /home/wolfgang/snap/crystal/common/.cache/crystal/crystal-run-merger.tmp in '_start'
# from ???Metadata
Metadata
Assignees
Labels
No labels