diff --git a/libs/imageio/src/ImageDecoder.cpp b/libs/imageio/src/ImageDecoder.cpp index 664df3d3ce..f787a75fbb 100644 --- a/libs/imageio/src/ImageDecoder.cpp +++ b/libs/imageio/src/ImageDecoder.cpp @@ -576,11 +576,13 @@ LinearImage EXRDecoder::decode() { int ret = LoadEXRFromMemory(&rgba, &width, &height, src.data(), src.size(), &error); if (ret != TINYEXR_SUCCESS) { std::cerr << "Could not decode OpenEXR: " << error << std::endl; + FreeEXRErrorMessage(error); mStream.seekg(mStreamStartPos); return LinearImage(); } - src.resize(0); + src.clear(); + src.shrink_to_fit(); LinearImage image(width, height, 3); @@ -596,6 +598,8 @@ LinearImage EXRDecoder::decode() { } } + free(rgba); + return image; } catch(std::runtime_error& e) { // reset the stream, like we found it diff --git a/third_party/tinyexr/tinyexr.h b/third_party/tinyexr/tinyexr.h index a636bda5df..d3199574f3 100755 --- a/third_party/tinyexr/tinyexr.h +++ b/third_party/tinyexr/tinyexr.h @@ -11293,6 +11293,13 @@ int LoadEXRFromMemory(float **out_rgba, int *width, int *height, return ret; } + // This utility function does not yet support tiled images. + if (exr_image.tiles) { + ret = TINYEXR_ERROR_UNSUPPORTED_FORMAT; + tinyexr::SetErrorMessage("Tiled EXR images are not yet supported", err); + return ret; + } + // RGBA int idxR = -1; int idxG = -1; diff --git a/third_party/tinyexr/tnt/README.md b/third_party/tinyexr/tnt/README.md index 0244d51a0e..b6336ffe2a 100644 --- a/third_party/tinyexr/tnt/README.md +++ b/third_party/tinyexr/tnt/README.md @@ -6,3 +6,13 @@ the following directories to save some disk space: - `test` Make sure the LICENSE file remains and is up to date. + +We also made a small change to `LoadEXRFromMemory` by adding this right after it calls +`LoadEXRImageFromMemory`: + + // This utility function does not yet support tiled images. + if (exr_image.tiles) { + ret = TINYEXR_ERROR_UNSUPPORTED_FORMAT; + tinyexr::SetErrorMessage("Tiled EXR images are not yet supported", err); + return ret; + }