Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/hdf5_plugins/ZSTD/src/H5Zzstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ H5Z_filter_zstd(unsigned int flags, size_t cd_nelmts, const unsigned int cd_valu
if (flags & H5Z_FLAG_REVERSE) {
/* We're decompressing */
size_t decompSize = ZSTD_getFrameContentSize(*buf, origSize);

@pimlu pimlu Jul 29, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically decompSize should be an unsigned long long but on 64-bit systems the outcome is the same. Let me know if I should update this in the same PR.

if (decompSize == 0 || decompSize == ZSTD_CONTENTSIZE_UNKNOWN ||
decompSize == ZSTD_CONTENTSIZE_ERROR)
goto error;

if (NULL == (outbuf = malloc(decompSize)))
goto error;

decompSize = ZSTD_decompress(outbuf, decompSize, inbuf, origSize);
if (ZSTD_isError(decompSize))
goto error;

#ifdef ZSTD_DEBUG
fprintf(stderr, " decompressing nbytes: %ld\n", decompSize);
Expand Down Expand Up @@ -104,6 +110,8 @@ H5Z_filter_zstd(unsigned int flags, size_t cd_nelmts, const unsigned int cd_valu
goto error;

compSize = ZSTD_compress(outbuf, compSize, inbuf, origSize, aggression);
if (ZSTD_isError(compSize))
goto error;

#ifdef ZSTD_DEBUG
fprintf(stderr, " compressing nbytes: %ld\n", compSize);
Expand Down