Skip to content

Commit 3ecc8fa

Browse files
antond-wetalgritz
authored andcommitted
fix(raw) check for nullptr in raw input plugin (AcademySoftwareFoundation#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]>
1 parent 1d4deee commit 3ecc8fa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/raw.imageio/rawinput.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,13 @@ RawInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
15271527
if (!m_process) {
15281528
// The user has selected not to apply any debayering.
15291529

1530+
if (m_processor->imgdata.rawdata.raw_image == nullptr) {
1531+
errorfmt(
1532+
"Raw undebayered data is not available for this file \"{}\"",
1533+
m_filename);
1534+
return false;
1535+
}
1536+
15301537
// The raw_image buffer might contain junk pixels that are usually trimmed off
15311538
// we must index into the raw buffer, taking these into account
15321539
auto& sizes = m_processor->imgdata.sizes;

0 commit comments

Comments
 (0)