From f3b659d5ebe3d82d598344e69584ac9653abd9a7 Mon Sep 17 00:00:00 2001 From: Conrad Poelman Date: Fri, 1 Aug 2025 14:40:09 -0400 Subject: [PATCH] Throw helpful exception on null blockingInfo, in ImageReader.cpp When errors occur in nitf_ImageIO_getBlockingInfo, it returns a NULL pointer and sets error to a helpful message. Previously the code wasn't checking for this, leading to a later less helpful error like "Invalid handle". This enables the more precise errors to be passed up the call stack to the caller. --- modules/c++/nitf/source/ImageReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/c++/nitf/source/ImageReader.cpp b/modules/c++/nitf/source/ImageReader.cpp index 5b02f8746..6d78b7ea3 100644 --- a/modules/c++/nitf/source/ImageReader.cpp +++ b/modules/c++/nitf/source/ImageReader.cpp @@ -51,6 +51,8 @@ nitf::BlockingInfo ImageReader::getBlockingInfo() const { nitf_BlockingInfo* blockingInfo = nitf_ImageReader_getBlockingInfo(getNativeOrThrow(), &error); + if (!blockingInfo) + throw nitf::NITFException(&error); // This creates a new object, not a reference to a field, // So need to tell the wrapper it needs to destruct itself nitf::BlockingInfo cppBlockingInfo(blockingInfo);