From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6442 invoked by alias); 30 May 2013 17:39:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 6428 invoked by uid 89); 30 May 2013 17:39:39 -0000 X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,TW_EG autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 30 May 2013 17:39:24 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4UHdMte010547 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 30 May 2013 13:39:22 -0400 Received: from barimba (ovpn-113-72.phx2.redhat.com [10.3.113.72]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4UHdKiB007741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 30 May 2013 13:39:21 -0400 From: Tom Tromey To: Yao Qi Cc: Subject: Re: [PATCH 39/40] fix compile_rx_or_error References: <519055B5.10803@codesourcery.com> <87y5bjc4dq.fsf@fleche.redhat.com> Date: Thu, 30 May 2013 17:39:00 -0000 In-Reply-To: <87y5bjc4dq.fsf@fleche.redhat.com> (Tom Tromey's message of "Mon, 13 May 2013 08:59:29 -0600") Message-ID: <87bo7ss6yf.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-05/txt/msg01091.txt.bz2 Yao> Do we need an assert on RX here? Tom> It can't hurt, but I think the subsequent regcomp will just crash. Tom> I will add one. For the record, here is what I am checking in. Tom * probe.c (collect_probes): Check arguments for NULL before calling compile_rx_or_error. * utils.c (compile_rx_or_error): Require 'rx' to be non-NULL. Remove NULL return. diff --git a/gdb/probe.c b/gdb/probe.c index 05bdd1b..3086f4d 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -245,9 +245,12 @@ collect_probes (char *objname, char *provider, char *probe_name, cleanup = make_cleanup (VEC_cleanup (probe_p), &result); cleanup_temps = make_cleanup (null_cleanup, NULL); - compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp")); - compile_rx_or_error (&probe_pat, probe_name, _("Invalid probe regexp")); - compile_rx_or_error (&obj_pat, objname, _("Invalid object file regexp")); + if (provider != NULL) + compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp")); + if (probe_name != NULL) + compile_rx_or_error (&probe_pat, probe_name, _("Invalid probe regexp")); + if (objname != NULL) + compile_rx_or_error (&obj_pat, objname, _("Invalid object file regexp")); ALL_OBJFILES (objfile) { diff --git a/gdb/utils.c b/gdb/utils.c index c25dadf..18ee9bb 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1127,16 +1127,15 @@ get_regcomp_error (int code, regex_t *rx) } /* Compile a regexp and throw an exception on error. This returns a - cleanup to free the resulting pattern on success. If RX is NULL, - this does nothing and returns NULL. */ + cleanup to free the resulting pattern on success. RX must not be + NULL. */ struct cleanup * compile_rx_or_error (regex_t *pattern, const char *rx, const char *message) { int code; - if (!rx) - return NULL; + gdb_assert (rx != NULL); code = regcomp (pattern, rx, REG_NOSUB); if (code != 0)