fix(gif): address corrupt files with bad resolutions and overflow int (#5257)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
This commit is contained in:
Larry Gritz
2026-06-29 09:57:37 -07:00
committed by GitHub
parent bb5beea8aa
commit cf7152d479
4 changed files with 14 additions and 2 deletions
+6 -2
View File
@@ -337,7 +337,8 @@ GIFInput::read_subimage_data()
if (m_subimage == 0 || m_previous_disposal_method == DISPOSE_BACKGROUND) {
// make whole canvas transparent
std::fill(m_canvas.begin(), m_canvas.end(), 0x00);
m_canvas.clear();
m_canvas.resize(m_spec.image_pixels() * size_t(4), 0x00);
}
// decode scanline index if image is interlaced
@@ -412,7 +413,6 @@ GIFInput::seek_subimage(int subimage, int miplevel)
return false;
}
m_subimage = -1;
m_canvas.resize(m_gif_file->SWidth * m_gif_file->SHeight * 4);
}
// skip subimages preceding the requested one
@@ -436,6 +436,10 @@ GIFInput::seek_subimage(int subimage, int miplevel)
m_spec.full_width = m_spec.width;
m_spec.full_depth = m_spec.depth;
if (!check_open(m_spec, { 0, 32768, 0, 32768, 0, 1, 0, 4 })) {
return false;
}
m_subimage = subimage;
// draw subimage on canvas
+3
View File
@@ -106,3 +106,6 @@ tahoe-tiny.gif : 128 x 96, 4 channel, uint8 gif
oiio:ColorSpace: "srgb_rec709_scene"
oiio:LoopCount: 0
oiio:Movie: 1
oiiotool ERROR: read : "src/crash_4163.gif": Wrong record type detected
Full command line was:
> oiiotool -nostderr -oiioattrib try_all_readers 0 src/crash_4163.gif -o test.exr
+5
View File
@@ -15,3 +15,8 @@ for f in files:
# Test write / conversion to GIF
command += oiiotool (OIIO_TESTSUITE_ROOT+"/common/tahoe-tiny.tif -o tahoe-tiny.gif")
command += info_command ("tahoe-tiny.gif")
# Regression tests
command += oiiotool ("-nostderr -oiioattrib try_all_readers 0 src/crash_4163.gif -o test.exr", failureok = True)
outputs = [ "tahoe-tiny.gif", "out.txt" ]
Binary file not shown.