From eda3ff1cc21f3a79a34cbf8a7e845b064f12131c Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Thu, 21 Sep 2023 00:29:57 -0300 Subject: [PATCH] Reapply commit a2b3b1e that was missing --- src/rcore.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 32b3086a9..4f584ae5a 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1691,10 +1691,12 @@ unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDa #if defined(SUPPORT_COMPRESSION_API) // Compress data and generate a valid DEFLATE stream - struct sdefl sdefl = { 0 }; - int bounds = sdefl_bound(dataSize); + struct sdefl *sdefl = RL_CALLOC(1, sizeof(struct sdefl)); // WARNING: Possible stack overflow, struct sdefl is almost 1MB + int bounds = dataSize*2;//sdefl_bound(dataSize); compData = (unsigned char *)RL_CALLOC(bounds, 1); - *compDataSize = sdeflate(&sdefl, compData, data, dataSize, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbiw + + *compDataSize = sdeflate(sdefl, compData, data, dataSize, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbiw + RL_FREE(sdefl); TRACELOG(LOG_INFO, "SYSTEM: Compress data: Original size: %i -> Comp. size: %i", dataSize, *compDataSize); #endif