From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100661 invoked by alias); 20 Aug 2017 14:06:27 -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 100611 invoked by uid 89); 20 Aug 2017 14:06:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:2017082 X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 20 Aug 2017 14:06:19 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy6.mail.unifiedlayer.com (Postfix) with ESMTP id 0342C1E08A2 for ; Sun, 20 Aug 2017 07:54:08 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id zRu41v00W2f2jeq01Ru7gC; Sun, 20 Aug 2017 07:54:07 -0600 X-Authority-Analysis: v=2.2 cv=FrR1xyjq c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=KeKAF7QvOSUA:10 a=zstS-IiYAAAA:8 a=20KFwNOVAAAA:8 a=o3tofT7iySIfzKeRGfgA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-24-97.hlrn.qwest.net ([75.166.24.97]:52042 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1djQg0-002nd1-Gy; Sun, 20 Aug 2017 07:54:04 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/2] Fix erroneous cleanup use in add_solib_catchpoint Date: Sun, 20 Aug 2017 14:06:00 -0000 Message-Id: <20170820135402.1213-2-tom@tromey.com> In-Reply-To: <20170820135402.1213-1-tom@tromey.com> References: <20170820135402.1213-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1djQg0-002nd1-Gy X-Source-Sender: 75-166-24-97.hlrn.qwest.net (bapiya.Home) [75.166.24.97]:52042 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-08/txt/msg00369.txt.bz2 I happened to notice that add_solib_catchpoint allocated the new catchpoint with "new" but installed a cleanup using "xfree". This patch fixes the bug by changing the function to use std::unique_ptr instead. gdb/ChangeLog 2017-08-19 Tom Tromey * breakpoint.c (add_solib_catchpoint): Use std::unique_ptr. --- gdb/ChangeLog | 4 ++++ gdb/breakpoint.c | 10 +++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7ad3f4c..339ab3a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-08-19 Tom Tromey + + * breakpoint.c (add_solib_catchpoint): Use std::unique_ptr. + 2017-08-18 Tom Tromey Pedro Alves diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index bc681cf..135741a 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8464,16 +8464,13 @@ static struct breakpoint_ops catch_solib_breakpoint_ops; void add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled) { - struct solib_catchpoint *c; struct gdbarch *gdbarch = get_current_arch (); - struct cleanup *cleanup; if (!arg) arg = ""; arg = skip_spaces_const (arg); - c = new solib_catchpoint (); - cleanup = make_cleanup (xfree, c); + std::unique_ptr c (new solib_catchpoint ()); if (*arg != '\0') { @@ -8483,13 +8480,12 @@ add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled) } c->is_load = is_load; - init_catchpoint (c, gdbarch, is_temp, NULL, + init_catchpoint (c.get (), gdbarch, is_temp, NULL, &catch_solib_breakpoint_ops); c->enable_state = enabled ? bp_enabled : bp_disabled; - discard_cleanups (cleanup); - install_breakpoint (0, c, 1); + install_breakpoint (0, c.release (), 1); } /* A helper function that does all the work for "catch load" and -- 2.9.4