From 50fe45f43ca24fc75c836afa9ef688b47ba6767b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 3 Mar 2025 16:31:41 -0700 Subject: [PATCH] [COLR] Fix memory leak --- src/OT/Color/COLR/COLR.hh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index 309ac2101..4f250a9d1 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -2120,7 +2120,18 @@ struct COLR accelerator_t (hb_face_t *face) { colr = hb_sanitize_context_t ().reference_table (face); } - ~accelerator_t () { this->colr.destroy (); } + ~accelerator_t () + { + auto *scratch = cached_scratch.get_relaxed (); + if (scratch) + { + scratch->~hb_colr_scratch_t (); + hb_free (scratch); + } + + colr.destroy (); + } + bool has_data () const { return colr->has_data (); }