Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/cineon.imageio/cineoninput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions testsuite/cineon/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions testsuite/cineon/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Binary file added testsuite/cineon/src/broken_bitdepth2.cin
Binary file not shown.
Loading