portability: fix file size check on Windows

Resolved an issue where parsing failed due to mismatch
between file size obtained via `ftell` and the actual
bytes read by `fread`. This occurred because newline
translation (`\r\n` to `\n`) in text mode altered the byte
count, leading to incorrect assumptions about the data size.
This commit is contained in:
Mira Grudzinska 2024-12-21 00:27:47 +01:00
parent bed521a08c
commit 0fc2e6adcb

View file

@ -233,11 +233,7 @@ bool LottieLoader::open(const string& path)
auto content = (char*)(malloc(sizeof(char) * size + 1));
fseek(f, 0, SEEK_SET);
auto ret = fread(content, sizeof(char), size, f);
if (ret < size) {
fclose(f);
return false;
}
size = fread(content, sizeof(char), size, f);
content[size] = '\0';
fclose(f);