fixed a limit case scenario
authorYann Collet <cyan@fb.com>
Wed, 16 Nov 2016 01:51:29 +0000 (17:51 -0800)
committerYann Collet <cyan@fb.com>
Wed, 16 Nov 2016 01:51:29 +0000 (17:51 -0800)
lib/lz4frame.c

index c8e5bde..3c2b788 100644 (file)
@@ -897,10 +897,11 @@ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcS
             FREEMEM(dctxPtr->tmpIn);
             dctxPtr->tmpIn = (BYTE*)ALLOCATOR(dctxPtr->maxBlockSize);
             if (dctxPtr->tmpIn == NULL) return err0r(LZ4F_ERROR_allocation_failed);
-            dctxPtr->maxBufferSize = bufferNeeded;
             FREEMEM(dctxPtr->tmpOutBuffer);
+            dctxPtr->maxBufferSize = 0;
             dctxPtr->tmpOutBuffer= (BYTE*)ALLOCATOR(bufferNeeded);
             if (dctxPtr->tmpOutBuffer== NULL) return err0r(LZ4F_ERROR_allocation_failed);
+            dctxPtr->maxBufferSize = bufferNeeded;
     }   }
     dctxPtr->tmpInSize = 0;
     dctxPtr->tmpInTarget = 0;