]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
ZSTD_CCtx_setParameter() only works during initialization stage
authorYann Collet <cyan@fb.com>
Fri, 19 May 2017 18:04:41 +0000 (11:04 -0700)
committerYann Collet <cyan@fb.com>
Fri, 19 May 2017 18:04:41 +0000 (11:04 -0700)
and generate a stage_wrong error otherwise.

lib/compress/zstd_compress.c

index 69b42cc8079c8dd0cd96f1106e534a24422cc50a..a3d4ebe7f0237421ef57b9f25291c655404855a9 100644 (file)
@@ -223,7 +223,14 @@ static void ZSTD_cLevelToCParams(ZSTD_CCtx* cctx)
 
 size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value)
 {
-#   define CLAMPCHECK(val,min,max) { if ((val<min) | (val>max)) return ERROR(compressionParameter_unsupported); }
+#   define CLAMPCHECK(val,min,max) {                         \
+        if ((val<min) | (val>max)) {                         \
+            return ERROR(compressionParameter_unsupported);  \
+    }   }
+
+    if (cctx->streamStage != zcss_init) {
+        return ERROR(stage_wrong);
+    }
 
     switch(param)
     {