[Openexr-devel] Memory-Mapped files and DWA compression
From:
darby johnston
Subject:
[Openexr-devel] Memory-Mapped files and DWA compression
Date:
Tue, 30 Oct 2018 16:11:37 +0000 (UTC)
Hi all,
I was implementing memory-mapped loading of OpenEXR images for my viewer and noticed a crash when loading DWA compressed files. Taking a look at the code it seems that DwaCompressor::uncompress() is writing to the const char * data that is passed to it:
int DwaCompressor::uncompress (const char *inPtr, int inSize, IMATH_NAMESPACE::Box2i range, const char *&outPtr)
When the passed data is memory-mapped as read-only this causes a memory access violation on Windows. Copying the data to a temporary buffer and then doing the Xdr conversion fixes the issue; the performance difference should be negligible since this is only for some header data, probably less than 100 bytes. If this seems like an OK change I've attached a patch or can also submit a git pull request.