From: K.Kosako Date: Wed, 27 Mar 2019 06:18:28 +0000 (+0900) Subject: fix memory leaks X-Git-Tag: v6.9.2_rc1~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b010990387ccfcefa09c093dbb2482832a77e79c;p=onig fix memory leaks --- diff --git a/src/regcomp.c b/src/regcomp.c index c33be15..4390eea 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -198,6 +198,12 @@ ops_new(regex_t* reg) return ONIG_NORMAL; } +static int +is_in_string_pool(regex_t* reg, UChar* s) +{ + return (s >= reg->string_pool && s < reg->string_pool_end); +} + static void ops_free(regex_t* reg) { @@ -219,10 +225,12 @@ ops_free(regex_t* reg) switch (opcode) { case OP_EXACTMBN: - // IN STRING POOL xfree(op->exact_len_n.s); + if (! is_in_string_pool(reg, op->exact_len_n.s)) + xfree(op->exact_len_n.s); break; case OP_EXACTN: case OP_EXACTMB2N: case OP_EXACTMB3N: case OP_EXACTN_IC: - // IN STRING POOL xfree(op->exact_n.s); + if (! is_in_string_pool(reg, op->exact_n.s)) + xfree(op->exact_n.s); break; case OP_EXACT1: case OP_EXACT2: case OP_EXACT3: case OP_EXACT4: case OP_EXACT5: case OP_EXACTMB2N1: case OP_EXACTMB2N2: