From 168999c5a9a880c23fec7492ccd2b35818acb5e7 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 22 Dec 2020 10:42:11 +0900 Subject: [PATCH] common shape: ++safety null check after memory allocation. --- src/lib/tvgShapeImpl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/tvgShapeImpl.h b/src/lib/tvgShapeImpl.h index f5a2dfa8..82b56ed2 100644 --- a/src/lib/tvgShapeImpl.h +++ b/src/lib/tvgShapeImpl.h @@ -309,7 +309,10 @@ struct Shape::Impl stroke->dashPattern = nullptr; } - if (!stroke->dashPattern) stroke->dashPattern = static_cast(malloc(sizeof(float) * cnt)); + if (!stroke->dashPattern) { + stroke->dashPattern = static_cast(malloc(sizeof(float) * cnt)); + if (!stroke->dashPattern) return false; + } for (uint32_t i = 0; i < cnt; ++i) stroke->dashPattern[i] = pattern[i];