From 0b2a884fe244e745adc9d3565edf26cb7ea2c852 Mon Sep 17 00:00:00 2001 From: Ibrahn Sahir Date: Thu, 15 Nov 2018 13:36:40 +0000 Subject: [PATCH] Assign pointer null in RegEx::clear to avoid double free on destruction. (cherry picked from commit f8a1c77fcf1f501317f04528c31088d19e47ae86) --- modules/regex/regex.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 5108a91652b..324dff72c2f 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -178,13 +178,17 @@ void RegEx::clear() { if (sizeof(CharType) == 2) { - if (code) + if (code) { pcre2_code_free_16((pcre2_code_16 *)code); + code = NULL; + } } else { - if (code) + if (code) { pcre2_code_free_32((pcre2_code_32 *)code); + code = NULL; + } } }