Skip to content

Commit e45a625

Browse files
authored
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 de6cb3e commit e45a625

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
@@ -1516,6 +1516,13 @@ RawInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
15161516
if (!m_process) {
15171517
// The user has selected not to apply any debayering.
15181518

1519+
if (m_processor->imgdata.rawdata.raw_image == nullptr) {
1520+
errorfmt(
1521+
"Raw undebayered data is not available for this file \"{}\"",
1522+
m_filename);
1523+
return false;
1524+
}
1525+
15191526
// The raw_image buffer might contain junk pixels that are usually trimmed off
15201527
// we must index into the raw buffer, taking these into account
15211528
auto& sizes = m_processor->imgdata.sizes;

0 commit comments

Comments
 (0)