From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11893 invoked by alias); 10 Feb 2010 19:03:10 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 11810 invoked by uid 22791); 10 Feb 2010 19:03:09 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org From: Tom Tromey To: Project Archer Subject: [expr-cumulative] FYI: avoid memory leak Reply-To: tromey@redhat.com Date: Wed, 10 Feb 2010 19:03:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2010-q1/txt/msg00076.txt.bz2 I'm checking this in on the expr-cumulative as obvious. This avoids a memory leak in the C lexer. Tom 2010-02-10 Tom Tromey * c-exp.y (yylex): Use alloca, not savestring. diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 459177a..f8c23e0 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -2447,7 +2447,11 @@ yylex (void) int hextype; if (name_prefix != NULL) - tmp = savestring (name_prefix, name_prefix_len+namelen); + { + tmp = alloca (name_prefix_len + namelen + 1); + memcpy (tmp, name_prefix, name_prefix_len + namelen); + tmp[name_prefix_len + namelen] = '\0'; + } sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN,