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,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,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 1881A1F4B6 for ; Wed, 24 Jul 2019 03:03:21 +0000 (UTC) Received: from localhost ([::1]:48278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hq7Yl-0004yS-Pq for normalperson@yhbt.net; Tue, 23 Jul 2019 23:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35407) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hq7Yi-0004yA-GQ for bug-gnulib@gnu.org; Tue, 23 Jul 2019 23:03:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hq7Yh-00036I-Hx for bug-gnulib@gnu.org; Tue, 23 Jul 2019 23:03:16 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::10]:31075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hq7Yg-00035Q-ST for bug-gnulib@gnu.org; Tue, 23 Jul 2019 23:03:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1563937391; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=xYY6s784nWFh6HdtJLphxIcspF6DZGnA1vhTSyAjmv8=; b=qbldfvg6R/JoeV/+Bwn+j2VuO0c0sfP1vkqDkWQn9YP883xdGeR5namPzJmBPqV05o JBBZSpZrJU0+QCsrXploWqi1wpCJv3nPqIJjhfqjzOISxEW6aiELQxgJ09p5HAvkyadg Vk8usOuqvcBblGjxdsDX3TCigHpXKdSilx4eY00LtMlxyIlz2kE3vvlf2q/j3yr1m7Ho agZ4SYa9gLYwg16Y3x0Cqhi4g+4F/UZ4grNMTnHP2dSRerK8Xmh4XnkjwNLyw9OMdb8Q TDqyqLGw3OqH5wxxjjSPLfP6jCUeATifP/rNYh+x/rn8r40Qdlugp7O0K9WZNImOl4i7 Ll/A== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGaf0zJZW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.24 DYNA|AUTH) with ESMTPSA id v018bcv6O33AMSr (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 24 Jul 2019 05:03:10 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: regex: avoid memory leak Date: Wed, 24 Jul 2019 05:03:08 +0200 Message-ID: <15819003.QUfdhuhlib@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-154-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::10 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: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Can someone please review this? 2019-07-23 Bruno Haible regex: Avoid memory leak. Reported by Coverity (CID 1484201). * lib/regex_internal.c (create_cd_newstate): Free newstate if we cannot allocate newstate->entrance_nodes. diff --git a/lib/regex_internal.c b/lib/regex_internal.c index 9004ce8..02b2e09 100644 --- a/lib/regex_internal.c +++ b/lib/regex_internal.c @@ -1724,7 +1724,10 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, } if (re_node_set_init_copy (newstate->entrance_nodes, nodes) != REG_NOERROR) - return NULL; + { + free_state (newstate); + return NULL; + } nctx_nodes = 0; newstate->has_constraint = 1; }