From f71faf5feca3bb51e34bec7387c4be7c988447a8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 25 Feb 2025 11:35:21 -0700 Subject: [PATCH] [VARC] Fix buffer scratch borrowing --- src/OT/Var/VARC/VARC.hh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh index faf0d59c1..30e54b6bd 100644 --- a/src/OT/Var/VARC/VARC.hh +++ b/src/OT/Var/VARC/VARC.hh @@ -162,24 +162,16 @@ struct VARC { if (!table->has_data ()) return false; - hb_glyf_scratch_t *scratch = nullptr; + hb_glyf_scratch_t *scratch; // Borrow the cached strach buffer. - retry: { - scratch = cached_scratch.get_relaxed (); - if (!scratch) + scratch = cached_scratch.get_acquire (); + if (!scratch || unlikely (!cached_scratch.cmpexch (scratch, nullptr))) { scratch = (hb_glyf_scratch_t *) hb_calloc (1, sizeof (hb_glyf_scratch_t)); if (unlikely (!scratch)) return true; - - if (!cached_scratch.cmpexch (scratch, nullptr)) - { - scratch->~hb_glyf_scratch_t (); - hb_free (scratch); - goto retry; - } } }