]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix #1412: Perform Signed Comparison When Setting Attach Dict Param
authorW. Felix Handte <w@felixhandte.com>
Mon, 12 Nov 2018 20:07:57 +0000 (12:07 -0800)
committerW. Felix Handte <w@felixhandte.com>
Mon, 12 Nov 2018 20:07:57 +0000 (12:07 -0800)
lib/compress/zstd_compress.c

index 7721325d78a9d31307e7311034c89c5d689ae010..436522ed39bb92180bdcd479771ee8668207cd94 100644 (file)
@@ -412,11 +412,14 @@ size_t ZSTD_CCtxParam_setParameter(
         CCtxParams->forceWindow = (value > 0);
         return CCtxParams->forceWindow;
 
-    case ZSTD_p_forceAttachDict :
-        CCtxParams->attachDictPref = value ?
-                                    (value > 0 ? ZSTD_dictForceAttach : ZSTD_dictForceCopy) :
+    case ZSTD_p_forceAttachDict : {
+        int signed_val = (int)value;
+        CCtxParams->attachDictPref = signed_val ?
+                                    (signed_val > 0 ? ZSTD_dictForceAttach :
+                                                      ZSTD_dictForceCopy) :
                                      ZSTD_dictDefaultAttach;
         return CCtxParams->attachDictPref;
+    }
 
     case ZSTD_p_nbWorkers :
 #ifndef ZSTD_MULTITHREAD