]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
add a paragraph on UB DCtx state after error
authorYann Collet <cyan@fb.com>
Mon, 18 Mar 2024 19:17:41 +0000 (12:17 -0700)
committerYann Collet <cyan@fb.com>
Mon, 18 Mar 2024 19:17:41 +0000 (12:17 -0700)
lib/zstd.h

index 115d7f2acca8fd83bf832752698a863045ce5562..d27e593179ba311caf4604581cbaf87e1b91d4d5 100644 (file)
@@ -904,6 +904,12 @@ ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
  * @return : 0 when a frame is completely decoded and fully flushed,
  *           or an error code, which can be tested using ZSTD_isError(),
  *           or any other value > 0, which means there is some decoding or flushing to do to complete current frame.
+ *
+ * Note: when an operation returns with an error code, the @zds state if left in undefined state.
+ *       It's UB to invoke `ZSTD_decompressStream()` on such a state.
+ *       In order to re-use such a state, it must be reset first,
+ *       which can be done explicitly (`ZSTD_DCtx_reset()`),
+ *       or is sometimes implied (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`)
  */
 ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);