From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 61B6D1F8C6 for ; Tue, 22 Jun 2021 15:36:19 +0000 (UTC) Received: from localhost ([::1]:58338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lviRm-0005L5-2j for normalperson@yhbt.net; Tue, 22 Jun 2021 11:36:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lviRi-0005KM-F1 for bug-gnulib@gnu.org; Tue, 22 Jun 2021 11:36:14 -0400 Received: from air.basealt.ru ([194.107.17.39]:54312) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lviRg-0005ho-Fa for bug-gnulib@gnu.org; Tue, 22 Jun 2021 11:36:14 -0400 Received: by air.basealt.ru (Postfix, from userid 490) id EDA7D58988B; Tue, 22 Jun 2021 15:36:09 +0000 (UTC) Received: from EGORI-MACHINE.malta.altlinux.ru (obninsk.basealt.ru [217.15.195.17]) by air.basealt.ru (Postfix) with ESMTPSA id 6AF8258988E; Tue, 22 Jun 2021 15:36:07 +0000 (UTC) From: Egor Ignatov To: eggert@cs.ucla.edu Subject: [PATCH] regex: fix assertion in re_node_set_insert Date: Tue, 22 Jun 2021 18:35:59 +0300 Message-Id: <20210622153559.1087338-2-egori@altlinux.org> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210622153559.1087338-1-egori@altlinux.org> References: <32c7255e-2e0d-2671-1641-2d02b13548c0@cs.ucla.edu> <20210622153559.1087338-1-egori@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=194.107.17.39; envelope-from=egori@altlinux.org; helo=air.basealt.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" * lib/regexec.c (proceed_next_node): Add duplicate insertion check for eps_via_nodes set. Signed-off-by: Egor Ignatov --- lib/regexec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/regexec.c b/lib/regexec.c index 23b984a21..c05b92783 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -1220,10 +1220,12 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, { re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; re_node_set *edests = &dfa->edests[node]; - bool ok = re_node_set_insert (eps_via_nodes, node); - if (__glibc_unlikely (! ok)) - return -2; - + if(!re_node_set_contains (eps_via_nodes, node)) + { + bool ok = re_node_set_insert (eps_via_nodes, node); + if (__glibc_unlikely (! ok)) + return -2; + } /* Pick a valid destination, or return -1 if none is found. */ Idx dest_node = -1; for (Idx i = 0; i < edests->nelem; i++) -- 2.29.3