mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 20:14:37 +00:00
sw_engine shape: prevent crash when wrong pair of commands & points.
add an exception handling, if the given points count is not matched with expected points count from commands. @Issue: https://github.com/Samsung/thorvg/issues/735
This commit is contained in:
parent
54b328b1a9
commit
f2252787ee
1 changed files with 7 additions and 0 deletions
|
@ -389,11 +389,13 @@ static bool _genOutline(SwShape* shape, const Shape* sdata, const Matrix* transf
|
||||||
//smart reservation
|
//smart reservation
|
||||||
auto outlinePtsCnt = 0;
|
auto outlinePtsCnt = 0;
|
||||||
auto outlineCntrsCnt = 0;
|
auto outlineCntrsCnt = 0;
|
||||||
|
auto closeCnt = 0;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < cmdCnt; ++i) {
|
for (uint32_t i = 0; i < cmdCnt; ++i) {
|
||||||
switch(*(cmds + i)) {
|
switch(*(cmds + i)) {
|
||||||
case PathCommand::Close: {
|
case PathCommand::Close: {
|
||||||
++outlinePtsCnt;
|
++outlinePtsCnt;
|
||||||
|
++closeCnt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PathCommand::MoveTo: {
|
case PathCommand::MoveTo: {
|
||||||
|
@ -412,6 +414,11 @@ static bool _genOutline(SwShape* shape, const Shape* sdata, const Matrix* transf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (static_cast<uint32_t>(outlinePtsCnt - closeCnt) > ptsCnt) {
|
||||||
|
TVGERR("SW_ENGINE", "Wrong a pair of the commands & points - required(%d), current(%d)", outlinePtsCnt - closeCnt, ptsCnt);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
++outlinePtsCnt; //for close
|
++outlinePtsCnt; //for close
|
||||||
++outlineCntrsCnt; //for end
|
++outlineCntrsCnt; //for end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue