diff --git a/src/gif.imageio/gifinput.cpp b/src/gif.imageio/gifinput.cpp index 3e01dd1bad..6a4a85fa88 100644 --- a/src/gif.imageio/gifinput.cpp +++ b/src/gif.imageio/gifinput.cpp @@ -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 diff --git a/testsuite/gif/ref/out.txt b/testsuite/gif/ref/out.txt index 9907cf85cf..0ed560899a 100644 --- a/testsuite/gif/ref/out.txt +++ b/testsuite/gif/ref/out.txt @@ -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 diff --git a/testsuite/gif/run.py b/testsuite/gif/run.py index 3d3a56956e..bf91f9ec4f 100755 --- a/testsuite/gif/run.py +++ b/testsuite/gif/run.py @@ -15,3 +15,8 @@ # 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" ] diff --git a/testsuite/gif/src/crash_4163.gif b/testsuite/gif/src/crash_4163.gif new file mode 100644 index 0000000000..eeb9f7ec74 Binary files /dev/null and b/testsuite/gif/src/crash_4163.gif differ