diff --git a/src/cineon.imageio/cineoninput.cpp b/src/cineon.imageio/cineoninput.cpp index 330ba34c27..48f50e0ff8 100644 --- a/src/cineon.imageio/cineoninput.cpp +++ b/src/cineon.imageio/cineoninput.cpp @@ -102,8 +102,20 @@ CineonInput::open(const std::string& name, ImageSpec& newspec) int maxbits = 0; for (int i = 0; i < nchannels; i++) { int b(m_cin.header.BitDepth(i)); - if (b < 1 || b > 32) { + // libcineon's ComponentDataSize/ComponentByteCount only know how to + // handle these bit depths; anything else asserts (or worse, in a + // non-debug build) deep inside the vendored library. Reject bogus + // values here so we can give a proper error instead. + switch (b) { + case 8: + case 10: + case 12: + case 16: + case 32: + case 64: break; + default: errorfmt("Invalid bitdepth in channel {}: {} bits", i, b); + close(); return false; } maxbits = std::max(maxbits, b); diff --git a/testsuite/cineon/ref/out.txt b/testsuite/cineon/ref/out.txt index 74ad31e404..07f06a1928 100644 --- a/testsuite/cineon/ref/out.txt +++ b/testsuite/cineon/ref/out.txt @@ -36,3 +36,6 @@ Reading ../oiio-images/cineon/checker.cin oiiotool ERROR: read : "src/broken_bitdepth.cin": Invalid number of channels 255 (must be 1-8) Full command line was: > oiiotool --info --hash src/broken_bitdepth.cin +oiiotool ERROR: read : "src/broken_bitdepth2.cin": Invalid bitdepth in channel 0: 26 bits +Full command line was: +> oiiotool --info --hash src/broken_bitdepth2.cin diff --git a/testsuite/cineon/run.py b/testsuite/cineon/run.py index e73803c963..9e01f91ed5 100755 --- a/testsuite/cineon/run.py +++ b/testsuite/cineon/run.py @@ -14,5 +14,8 @@ # Regression tests for broken files command += info_command ("src/broken_bitdepth.cin", verbose=False, failureok=True) +# Regression test for a per-channel bit depth libcineon doesn't recognize +# (used to assert/abort inside CineonHeader.cpp instead of erroring out). +command += info_command ("src/broken_bitdepth2.cin", verbose=False, failureok=True) outputs = [ "out.txt" ] diff --git a/testsuite/cineon/src/broken_bitdepth2.cin b/testsuite/cineon/src/broken_bitdepth2.cin new file mode 100644 index 0000000000..fdee065778 Binary files /dev/null and b/testsuite/cineon/src/broken_bitdepth2.cin differ