mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-16 04:54:39 +00:00
common shape: ++safety
null check after memory allocation.
This commit is contained in:
parent
849ed12050
commit
168999c5a9
1 changed files with 4 additions and 1 deletions
|
@ -309,7 +309,10 @@ struct Shape::Impl
|
|||
stroke->dashPattern = nullptr;
|
||||
}
|
||||
|
||||
if (!stroke->dashPattern) stroke->dashPattern = static_cast<float*>(malloc(sizeof(float) * cnt));
|
||||
if (!stroke->dashPattern) {
|
||||
stroke->dashPattern = static_cast<float*>(malloc(sizeof(float) * cnt));
|
||||
if (!stroke->dashPattern) return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < cnt; ++i)
|
||||
stroke->dashPattern[i] = pattern[i];
|
||||
|
|
Loading…
Add table
Reference in a new issue