sbcmsbgithub / snappy

Automatically exported from code.google.com/p/snappy
Other
0 stars 0 forks source link

Decompression issues with Snappy 1.1.2 #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have following compression & decompression functions:
static void Compress_Snappy(void * pvOutBuffer, int * pcbOutBuffer, void * 
pvInBuffer, int cbInBuffer)
{
    char* destBuffer = (char*)pvOutBuffer;
    size_t srcLen  = (size_t)cbInBuffer;
    size_t destLen = *pcbOutBuffer;

    // Perform compression
    snappy::RawCompress((const char *)pvInBuffer, srcLen, destBuffer, &destLen);

    // Give the size of the data to the caller
    *pcbOutBuffer = (int)destLen;
}

static int Decompress_Snappy(void * pvOutBuffer, int * pcbOutBuffer, void * 
pvInBuffer, int cbInBuffer)
{
    const char * srcBuffer = (char*)pvInBuffer;
    char * destBuffer = (char *)pvOutBuffer;
    size_t srcLen = cbInBuffer;
    size_t destLen = *pcbOutBuffer;
    size_t realUncompLen = 0;

    if (*srcBuffer == 0)
        return 0;

    // Invalid input.
    if (!snappy::GetUncompressedLength(srcBuffer, srcLen, &realUncompLen))
        return 0;

    // Buffer too small.
    if (destLen < realUncompLen)
        return 0;

    // Invalid input.
    if (!snappy::RawUncompress(srcBuffer, srcLen, destBuffer))
        return 0;

    *pcbOutBuffer = (unsigned int)realUncompLen;
    return 1;
}

When I trying to decompress, I got crash (see scr1.jpg).
Just for the reference, on scr2.jpg you can see rawuncompress call with data 
it's got.
Configuration: VS2013, x64.
Computer specs, if matters: Win 8.1 x64, Intel Core i7 4700HQ, GeForce 870M.

Hope, someone could point me what I'm doing wrong...

Original issue reported on code.google.com by furious....@googlemail.com on 27 May 2014 at 12:15

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Where does your config.h come from? It looks broken to me; MSVC on x64 
shouldn't need to use memcpy for an unaligned 64-bit store.

If you really want to use MSVC, your needs may be better served by the MSVC 
packaging at http://snappy.angeloflogic.com/.

Original comment by se...@google.com on 27 May 2014 at 10:08

GoogleCodeExporter commented 9 years ago
Hello.
Thanks for you assistance.
After I defined __x64_86__ Snappy works fine!

Original comment by furious....@googlemail.com on 27 May 2014 at 12:00

GoogleCodeExporter commented 9 years ago

Original comment by se...@google.com on 27 May 2014 at 12:06