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 committed by Hermet Park
parent 285d1427ad
commit 72482877e7

View file

@ -234,11 +234,7 @@ bool LottieLoader::open(const char* 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);