Skip to content

Commit ba046a5

Browse files
committed
REVIEWED: DecompressData(), fixed buffer copying
1 parent f9e6c85 commit ba046a5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/rcore.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,19 +2563,19 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
25632563
#if defined(SUPPORT_COMPRESSION_API)
25642564
// Decompress data from a valid DEFLATE stream
25652565
unsigned char *data0 = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
2566-
int length = sinflate(data, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize);
2566+
int size = sinflate(data0, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize);
25672567

25682568
// WARNING: RL_REALLOC can make (and leave) data copies in memory,
25692569
// that can be a security concern in case of compression of sensitive data
25702570
// So, we use a second buffer to copy data manually, wiping original buffer memory
2571-
data = (unsigned char *)RL_CALLOC(length, 1);
2572-
memcpy(data, data0, length);
2571+
data = (unsigned char *)RL_CALLOC(size, 1);
2572+
memcpy(data, data0, size);
25732573
memset(data0, 0, MAX_DECOMPRESSION_SIZE*1024*1024); // Wipe memory, is memset() safe?
25742574
RL_FREE(data0);
25752575

2576-
TRACELOG(LOG_INFO, "SYSTEM: Decompress data: Comp. size: %i -> Original size: %i", compDataSize, length);
2576+
TRACELOG(LOG_INFO, "SYSTEM: Decompress data: Comp. size: %i -> Original size: %i", compDataSize, size);
25772577

2578-
*dataSize = length;
2578+
*dataSize = size;
25792579
#endif
25802580

25812581
return data;

0 commit comments

Comments
 (0)