From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21417 invoked by alias); 28 Jan 2004 01:44:19 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 21395 invoked from network); 28 Jan 2004 01:44:18 -0000 Received: from unknown (HELO localhost.redhat.com) (66.187.230.200) by sources.redhat.com with SMTP; 28 Jan 2004 01:44:18 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 08AB62B8F; Tue, 27 Jan 2004 20:40:50 -0500 (EST) Message-ID: <40171322.7080704@gnu.org> Date: Wed, 28 Jan 2004 01:44:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 MIME-Version: 1.0 To: Paul Hilfinger Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one References: <20040113100600.42C1FF2D70@nile.gnat.com> <40171150.5080708@gnu.org> Content-Type: multipart/mixed; boundary="------------030805020908030001080906" X-SW-Source: 2004-01/txt/msg00714.txt.bz2 This is a multi-part message in MIME format. --------------030805020908030001080906 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 72 > Anyway, I've committed the attached (slightly tweaked). Doh! Try ... --------------030805020908030001080906 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 1649 2004-01-27 Paul N. Hilfinger * breakpoint.c (breakpoint_re_set_one): Set b->cond, b->val, and b->exp to NULL after freeing so that error during re-parsing or evaluation of expressions associated with breakpoint don't eventually lead to re-freeing of storage. Committed by Andrew Cagney. Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.151 diff -u -r1.151 breakpoint.c --- breakpoint.c 27 Jan 2004 03:13:34 -0000 1.151 +++ breakpoint.c 28 Jan 2004 01:34:34 -0000 @@ -6970,12 +6970,22 @@ /* So for now, just use a global context. */ if (b->exp) - xfree (b->exp); + { + xfree (b->exp); + /* Avoid re-freeing b->exp if an error during the call to + parse_expression. */ + b->exp = NULL; + } b->exp = parse_expression (b->exp_string); b->exp_valid_block = innermost_block; mark = value_mark (); if (b->val) - value_free (b->val); + { + value_free (b->val); + /* Avoid re-freeing b->val if an error during the call to + evaluate_expression. */ + b->val = NULL; + } b->val = evaluate_expression (b->exp); release_value (b->val); if (VALUE_LAZY (b->val) && breakpoint_enabled (b)) @@ -6985,7 +6995,12 @@ { s = b->cond_string; if (b->cond) - xfree (b->cond); + { + xfree (b->cond); + /* Avoid re-freeing b->exp if an error during the call + to parse_exp_1. */ + b->cond = NULL; + } b->cond = parse_exp_1 (&s, (struct block *) 0, 0); } if (breakpoint_enabled (b)) --------------030805020908030001080906--