common shape: ++safety

null check after memory allocation.
This commit is contained in:
Hermet Park 2020-12-22 10:42:11 +09:00
parent 849ed12050
commit 168999c5a9

View file

@ -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];