From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26466 invoked by alias); 24 Jun 2008 06:33:11 -0000 Received: (qmail 26455 invoked by uid 22791); 24 Jun 2008 06:33:11 -0000 X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.185) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 24 Jun 2008 06:32:47 +0000 Received: by ti-out-0910.google.com with SMTP id d10so1202431tib.12 for ; Mon, 23 Jun 2008 23:32:44 -0700 (PDT) Received: by 10.110.53.14 with SMTP id b14mr6815500tia.8.1214289164578; Mon, 23 Jun 2008 23:32:44 -0700 (PDT) Received: by 10.110.109.4 with HTTP; Mon, 23 Jun 2008 23:32:44 -0700 (PDT) Message-ID: Date: Tue, 24 Jun 2008 12:32:00 -0000 From: teawater To: gdb-patches@sourceware.org Subject: [patch]: Fix memory leak of c-exp.y MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes 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: 2008-06/txt/msg00404.txt.bz2 Sorry that the format of this patch is not very well. So I send it again. c-exp.y has a memory leak in function parse_number. char *s is malloc at line 1211. There are returns at lines 1137, 1147, and 1157 without calling free. This patch is for the GDB CVS version. ChangeLog: 2008-06-21 Hui Zhu * gdb/c-exp.y: Fix memory leak of function parse_number --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1134,6 +1134,7 @@ parse_number (p, len, parsed_float, puti = builtin_type (current_gdbarch)->builtin_decfloat; decimal_from_string (putithere->typed_val_decfloat.val, 4, p); p[len] = saved_char; + free (s); return (DECFLOAT); } @@ -1144,6 +1145,7 @@ parse_number (p, len, parsed_float, puti = builtin_type (current_gdbarch)->builtin_decdouble; decimal_from_string (putithere->typed_val_decfloat.val, 8, p); p[len] = saved_char; + free (s); return (DECFLOAT); } @@ -1154,6 +1156,7 @@ parse_number (p, len, parsed_float, puti = builtin_type (current_gdbarch)->builtin_declong; decimal_from_string (putithere->typed_val_decfloat.val, 16, p); p[len] = saved_char; + free (s); return (DECFLOAT); }