From 0fc2e6adcb0dabef561c56aa669e5994494e6254 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sat, 21 Dec 2024 00:27:47 +0100 Subject: [PATCH] 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. --- src/loaders/lottie/tvgLottieLoader.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index ddf6aefb..46a0d1b2 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -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);