fixed uninitialization error in lz4frame
authorYann Collet <cyan@fb.com>
Thu, 10 Aug 2017 01:00:48 +0000 (18:00 -0700)
committerYann Collet <cyan@fb.com>
Thu, 10 Aug 2017 01:00:48 +0000 (18:00 -0700)
lib/lz4frame.c

index f9af991..07cbf56 100644 (file)
@@ -327,10 +327,6 @@ size_t LZ4F_compressFrame_usingCDict(void* dstBuffer, size_t dstCapacity,
     memset(&cctxI, 0, sizeof(cctxI));
     cctxI.version = LZ4F_VERSION;
     cctxI.maxBufferSize = 5 MB;   /* mess with real buffer size to prevent dynamic allocation; works only because autoflush==1 & stableSrc==1 */
-    if (prefs.compressionLevel < LZ4HC_CLEVEL_MIN) {
-        cctxI.lz4CtxPtr = &lz4ctx;
-        cctxI.lz4CtxLevel = 1;
-    }  /* fast compression context pre-created on stack */
 
     if (preferencesPtr!=NULL)
         prefs = *preferencesPtr;
@@ -344,6 +340,11 @@ size_t LZ4F_compressFrame_usingCDict(void* dstBuffer, size_t dstCapacity,
     if (srcSize <= LZ4F_getBlockSize(prefs.frameInfo.blockSizeID))
         prefs.frameInfo.blockMode = LZ4F_blockIndependent;   /* only one block => no need for inter-block link */
 
+    if (prefs.compressionLevel < LZ4HC_CLEVEL_MIN) {
+        cctxI.lz4CtxPtr = &lz4ctx;
+        cctxI.lz4CtxLevel = 1;
+    }  /* fast compression context pre-created on stack */
+
     memset(&options, 0, sizeof(options));
     options.stableSrc = 1;