Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: teawater <teawater@gmail.com>
To: gdb-patches@sourceware.org
Subject: [patch]: Fix memory leak of c-exp.y
Date: Tue, 24 Jun 2008 12:32:00 -0000	[thread overview]
Message-ID: <daef60380806232332n429917efu4eec3c7ca1731987@mail.gmail.com> (raw)

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 <teawater@gmail.com>
       * 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);
 	}


             reply	other threads:[~2008-06-24  6:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24 12:32 teawater [this message]
2008-06-24 14:04 ` Jan Kratochvil
2008-06-25 12:32   ` teawater
2008-06-25 13:11 ` Joel Brobecker
2008-06-25 13:40   ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2008-06-21 17:21 teawater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=daef60380806232332n429917efu4eec3c7ca1731987@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox