From c9c077ff5d144d0354ea625b56a11c3ec200a017 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 17 Mar 2023 10:45:03 -0700 Subject: [PATCH] fix double init call memory issue (#667) --- src/internal/colors/NeoGammaDynamicTableMethod.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/internal/colors/NeoGammaDynamicTableMethod.h b/src/internal/colors/NeoGammaDynamicTableMethod.h index d5db04a..2ccc9fe 100644 --- a/src/internal/colors/NeoGammaDynamicTableMethod.h +++ b/src/internal/colors/NeoGammaDynamicTableMethod.h @@ -112,18 +112,20 @@ public: static void Initialize(GammaCalcFunction calc, bool optimize16Bit = false) { + if (_hints) + { + delete [] _hints; + _hints = nullptr; + } + // first, iterate and fill 8 bit table for (uint16_t entry = 0; entry < 256; entry++) { _table[entry] = static_cast(255.0f * calc(entry / 255.0f) + 0.5f); } - if (!optimize16Bit) - { - // no optimization, so no 16 bit - _hints = nullptr; - } - else + // no optimization, so no 16 bit hints table + if (optimize16Bit) { NeoGamma16LowHint hints[256];