From 9afe5f973ea62957542830662f4c61d3ce795678 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 2 Jan 2023 11:44:29 -0700 Subject: [PATCH] [vector] Fix leak Discovered by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54767 --- src/hb-vector.hh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 8696003e9..1cb4d8fd6 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -233,6 +233,11 @@ struct hb_vector_t Type * realloc_vector (unsigned new_allocated) { + if (!new_allocated) + { + hb_free (arrayZ); + return nullptr; + } return (Type *) hb_realloc (arrayZ, new_allocated * sizeof (Type)); } template