From 097d3814ea255b9a6933ae5424d0c9aa4ef8afd2 Mon Sep 17 00:00:00 2001 From: Jinny You Date: Mon, 17 Mar 2025 10:22:33 +0900 Subject: [PATCH] lottie/slot: fix image deep copy logic When the datas are copied with deep copy, memory issue caused (SEGV on unknown address) due to these reasons: 1. `mimeType` is nullptr when it's not embedded(base64) data 2. datas(b64Data, mimeType) should not be clear, it's used for next slot copy in same pair. --- src/loaders/lottie/tvgLottieProperty.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/loaders/lottie/tvgLottieProperty.h b/src/loaders/lottie/tvgLottieProperty.h index 6e4f94cd..0df6c36e 100644 --- a/src/loaders/lottie/tvgLottieProperty.h +++ b/src/loaders/lottie/tvgLottieProperty.h @@ -947,18 +947,19 @@ struct LottieBitmap : LottieProperty if (shallow) { b64Data = rhs.b64Data; mimeType = rhs.mimeType; + + rhs.b64Data = nullptr; + rhs.mimeType = nullptr; } else { //TODO: optimize here by avoiding data copy TVGLOG("LOTTIE", "Shallow copy of the image data!"); b64Data = strdup(rhs.b64Data); mimeType = strdup(rhs.mimeType); } + size = rhs.size; width = rhs.width; height = rhs.height; - - rhs.b64Data = nullptr; - rhs.mimeType = nullptr; } };