aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2024-03-18 12:17:41 -0700
committerYann Collet <cyan@fb.com>2024-03-18 12:17:41 -0700
commit5d82c2b57c0f5f239ba712a7e6ec46c84a6ba02d (patch)
tree2809a18a1c35a8c44fb888e1592a1fe5d65f97cc
parentf5728da365e14a715a131434847f732ee84d8719 (diff)
downloadzstd-5d82c2b57c0f5f239ba712a7e6ec46c84a6ba02d.tar.gz
add a paragraph on UB DCtx state after error
-rw-r--r--lib/zstd.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/zstd.h b/lib/zstd.h
index 115d7f2a..d27e5931 100644
--- a/lib/zstd.h
+++ b/lib/zstd.h
@@ -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);