From 8215e7063232ffe3ff262c9839f1841e6d9bd7a1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 25 Feb 2023 12:37:11 -0700 Subject: [PATCH] [wasm-graphite] Memory hygiene --- src/wasm/graphite/shape.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wasm/graphite/shape.cc b/src/wasm/graphite/shape.cc index be704b5a0..ca15ebc55 100644 --- a/src/wasm/graphite/shape.cc +++ b/src/wasm/graphite/shape.cc @@ -117,7 +117,11 @@ shape (void *shape_plan, cluster_t *clusters = (cluster_t *) malloc (length * sizeof (cluster_t)); uint32_t *gids = (uint32_t *) malloc (length * sizeof (uint32_t)); if (!clusters || !gids) + { + free (clusters); + free (gids); return false; + } memset (clusters, 0, sizeof (clusters[0]) * length); codepoint_t *pg = gids;