Revert "Merge pull request 'Fix memory/null safety bugs (#74, #72, #69, #64, #60, #50, #49, #65)' (#80) from fix/memory-safety into main"
CI / lint (pull_request) Successful in 7s
CI / sanitizers (address) (pull_request) Successful in 14s
CI / sanitizers (undefined) (pull_request) Successful in 13s
CI / fuzz-build (pull_request) Successful in 12s
CI / coverage (pull_request) Successful in 9s
CI / build-and-test (pull_request) Successful in 53s
CI / valgrind (pull_request) Successful in 12s

This reverts commit ddfdb3825a, reversing
changes made to 504a3a4d4f.
This commit is contained in:
2026-07-20 19:36:09 +02:00
parent 5049a7bbf0
commit bcf5ffcf40
9 changed files with 18 additions and 144 deletions
+3 -12
View File
@@ -1,8 +1,7 @@
#include "compression.h"
#include "data.h"
#include "log.h"
#include <stdint.h>
#include <stdlib.h>
#include "stdlib.h"
#include "zstd.h"
#define INITIAL_DECOMPRESS_BUF_SIZE (1024 * 1024)
@@ -67,16 +66,8 @@ Data* data_decompress(Data* compressed_data) {
return NULL;
}
size_t buf_size = INITIAL_DECOMPRESS_BUF_SIZE;
if (!ZSTD_isError(dst_size) && dst_size > 0) {
if (dst_size > SIZE_MAX) {
log_message(LOG_LEVEL_ERROR,
"Decompressed size %llu exceeds addressable memory, using fallback buffer",
dst_size);
} else {
buf_size = (size_t)dst_size;
}
}
size_t buf_size =
(!ZSTD_isError(dst_size) && dst_size > 0) ? (size_t)dst_size : INITIAL_DECOMPRESS_BUF_SIZE;
Data* uncompressed_data = data_create_empty(buf_size);
if (!uncompressed_data) {
log_message(LOG_LEVEL_ERROR, "Failed to allocate decompression buffer");