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:
Michal Szczecinski 2021-06-04 13:24:29 +02:00 committed by Hermet Park
parent 718578532c
commit f8b636d4d0

View file

@ -43,11 +43,13 @@ Fill::~Fill()
Result Fill::colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept
{
if ((!colorStops && cnt > 0) || (colorStops && cnt == 0)) return Result::InvalidArguments;
if (cnt == 0) {
if (pImpl->colorStops) {
free(pImpl->colorStops);
pImpl->colorStops = nullptr;
pImpl->cnt = cnt;
pImpl->cnt = 0;
}
return Result::Success;
}