mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +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
|
||||
auto outlinePtsCnt = 0;
|
||||
auto outlineCntrsCnt = 0;
|
||||
auto closeCnt = 0;
|
||||
|
||||
for (uint32_t i = 0; i < cmdCnt; ++i) {
|
||||
switch(*(cmds + i)) {
|
||||
case PathCommand::Close: {
|
||||
++outlinePtsCnt;
|
||||
++closeCnt;
|
||||
break;
|
||||
}
|
||||
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
|
||||
++outlineCntrsCnt; //for end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue