openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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)
{
    ...
        Int64      *dst =  (((Int64 *)inPtr) + i);
        const char *src = "" *)(((Int64 *)inPtr) + i);

        Xdr::read<CharPtrIO> (src, *dst);
    ...
}

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.


Thanks, Darby

Attachment: ImfDwaCompressor.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]