mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
common gradient: Fix possible crash in color setter
Memcpy is not allowed on nullptr. If colorStops is invalid colors are cleared.
This commit is contained in:
parent
718578532c
commit
f8b636d4d0
1 changed files with 3 additions and 1 deletions
|
@ -43,11 +43,13 @@ Fill::~Fill()
|
||||||
|
|
||||||
Result Fill::colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept
|
Result Fill::colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept
|
||||||
{
|
{
|
||||||
|
if ((!colorStops && cnt > 0) || (colorStops && cnt == 0)) return Result::InvalidArguments;
|
||||||
|
|
||||||
if (cnt == 0) {
|
if (cnt == 0) {
|
||||||
if (pImpl->colorStops) {
|
if (pImpl->colorStops) {
|
||||||
free(pImpl->colorStops);
|
free(pImpl->colorStops);
|
||||||
pImpl->colorStops = nullptr;
|
pImpl->colorStops = nullptr;
|
||||||
pImpl->cnt = cnt;
|
pImpl->cnt = 0;
|
||||||
}
|
}
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue