Skip to content

Commit

Permalink
fix(raw) check for nullptr in raw input plugin (AcademySoftwareFounda…
Browse files Browse the repository at this point in the history
…tion#4448)

This adds a null pointer check in the raw input plugin when the user
requested raw bayer data for a file format which doesn't have it. With
this fix OIIO shows an error instead of crashing in such case.

This fixes the issue mentioned in the comments of AcademySoftwareFoundation#4361. The title issue
of AcademySoftwareFoundation#4361 has been resolved in LibRaw 0.22.0, so we can close that issue,
I guess.

This also fixes the crash on 5 out of 6 examples in AcademySoftwareFoundation#3115. The last one
is unrelated, and I don't have a good fix for that at this time (crash
due to the raw buffer having half resolution, with the pixel aspect
ratio of 0.5). Perhaps we could create a separate issue and close AcademySoftwareFoundation#3115.

I have not added any tests for this change specifically, as it is fairly
trivial.
I have started working on a more comprehensive test suite for the raw
plugin / rawtoaces, but it's not ready yet, and I'm not sure where it
should live at this stage.

Signed-off-by: Anton Dukhovnikov <[email protected]>
  • Loading branch information
antond-weta authored and lgritz committed Sep 29, 2024
1 parent 1d4deee commit 3ecc8fa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/raw.imageio/rawinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,13 @@ RawInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
if (!m_process) {
// The user has selected not to apply any debayering.

if (m_processor->imgdata.rawdata.raw_image == nullptr) {
errorfmt(
"Raw undebayered data is not available for this file \"{}\"",
m_filename);
return false;
}

// The raw_image buffer might contain junk pixels that are usually trimmed off
// we must index into the raw buffer, taking these into account
auto& sizes = m_processor->imgdata.sizes;
Expand Down

0 comments on commit 3ecc8fa

Please sign in to comment.