Skip to content

Commit

Permalink
Merge pull request #70 from juntyr/patch-1
Browse files Browse the repository at this point in the history
Fix UB for small array compression
  • Loading branch information
ayzk authored Dec 10, 2024
2 parents 10ebed0 + 0f3dde7 commit 780870a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/SZ3/api/sz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ template <class T>
char *SZ_compress(const SZ3::Config &config, const T *data, size_t &cmpSize) {
using namespace SZ3;

size_t bufferLen = 2 * config.num * sizeof(T);
// Ensure that the buffer can always hold the config and the lossless fallback
size_t bufferLen = config.size_est() + ZSTD_compressBound(config.num * sizeof(T));
auto buffer = new char[bufferLen];
cmpSize = SZ_compress(config, data, buffer, bufferLen);

Expand Down

0 comments on commit 780870a

Please sign in to comment.