lottie/parser: ++ null value handling

Note that, only dealt with a obivous case in practice.

issue: https://github.com/thorvg/thorvg/issues/2703
This commit is contained in:
Hermet Park 2024-09-03 17:21:23 +09:00 committed by Hermet Park
parent 31e7d44a92
commit c1c51fbc10
2 changed files with 12 additions and 10 deletions

View file

@ -318,17 +318,22 @@ void LottieParser::getValue(float& val)
} }
void LottieParser::getValue(Point& pt) bool LottieParser::getValue(Point& pt)
{ {
auto type = peekType();
if (type == kNullType) return false;
int i = 0; int i = 0;
auto ptr = (float*)(&pt); auto ptr = (float*)(&pt);
if (peekType() == kArrayType) enterArray(); if (type == kArrayType) enterArray();
while (nextArrayValue()) { while (nextArrayValue()) {
auto val = getFloat(); auto val = getFloat();
if (i < 2) ptr[i++] = val; if (i < 2) ptr[i++] = val;
} }
return true;
} }
@ -370,14 +375,11 @@ void LottieParser::parseSlotProperty(T& prop)
template<typename T> template<typename T>
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value) bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
{ {
if (KEY_AS("ti")) { if (KEY_AS("ti") && getValue(value.inTangent)) ;
value.hasTangent = true; else if (KEY_AS("to") && getValue(value.outTangent)) ;
getValue(value.inTangent); else return false;
} else if (KEY_AS("to")) {
value.hasTangent = true;
getValue(value.outTangent);
} else return false;
value.hasTangent = true;
return true; return true;
} }

View file

@ -61,8 +61,8 @@ private:
void getValue(ColorStop& color); void getValue(ColorStop& color);
void getValue(float& val); void getValue(float& val);
void getValue(uint8_t& val); void getValue(uint8_t& val);
void getValue(Point& pt);
void getValue(RGB24& color); void getValue(RGB24& color);
bool getValue(Point& pt);
template<typename T> bool parseTangent(const char *key, LottieVectorFrame<T>& value); template<typename T> bool parseTangent(const char *key, LottieVectorFrame<T>& value);
template<typename T> bool parseTangent(const char *key, LottieScalarFrame<T>& value); template<typename T> bool parseTangent(const char *key, LottieScalarFrame<T>& value);