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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
Reference in New Issue
Block a user