From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18714 invoked by alias); 26 Mar 2010 12:50:35 -0000 Received: (qmail 18703 invoked by uid 22791); 26 Mar 2010 12:50:34 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Mar 2010 12:50:30 +0000 Received: (qmail 10663 invoked from network); 26 Mar 2010 12:50:28 -0000 Received: from unknown (HELO macbook-2.local) (stan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Mar 2010 12:50:28 -0000 Message-ID: <4BACAD8F.3030909@codesourcery.com> Date: Fri, 26 Mar 2010 12:50:00 -0000 From: Stan Shebs User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: Pedro Alves CC: gdb-patches@sourceware.org, Stan Shebs Subject: Re: [PATCH/commit] Handle errors in tracepoint target agent References: <4BAC1426.5050003@codesourcery.com> <201003261140.09071.pedro@codesourcery.com> In-Reply-To: <201003261140.09071.pedro@codesourcery.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2010-03/txt/msg00882.txt.bz2 Pedro Alves wrote: > On Friday 26 March 2010 01:55:50, Stan Shebs wrote: > >> The error message is never NULL, I added the MI >> status bit overlooked before, >> > > But now, `error_desc' is leaking in the case you xmalloc it. > It was leaking before. :-) It needs to stick around indefinitely; it guess it would work to free an old one just before allocating a new one. > When you fix that leak, you'll stumble of the fact that > in some cases you have this: > > ts->error_desc = "" > > while in others you have this: > > ts->error_desc = (char *) xmalloc (p2 - p1 + 1); > No, because the p2 != p1 test prior ensures we only allocate non-empty strings. > How can you reliably know if you may xfree > ts->error_desc that way? xfree ("") is a no go. > Comparing a pointer with "" is also not good. > strlen. Stan