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.
This commit is contained in:
Jinny You 2025-03-17 10:22:33 +09:00 committed by Mira Grudzinska
parent 61360cf6db
commit 097d3814ea

View file

@ -947,18 +947,19 @@ struct LottieBitmap : LottieProperty
if (shallow) { if (shallow) {
b64Data = rhs.b64Data; b64Data = rhs.b64Data;
mimeType = rhs.mimeType; mimeType = rhs.mimeType;
rhs.b64Data = nullptr;
rhs.mimeType = nullptr;
} else { } else {
//TODO: optimize here by avoiding data copy //TODO: optimize here by avoiding data copy
TVGLOG("LOTTIE", "Shallow copy of the image data!"); TVGLOG("LOTTIE", "Shallow copy of the image data!");
b64Data = strdup(rhs.b64Data); b64Data = strdup(rhs.b64Data);
mimeType = strdup(rhs.mimeType); mimeType = strdup(rhs.mimeType);
} }
size = rhs.size; size = rhs.size;
width = rhs.width; width = rhs.width;
height = rhs.height; height = rhs.height;
rhs.b64Data = nullptr;
rhs.mimeType = nullptr;
} }
}; };