This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch]: Fix memory leak of c-exp.y
- From: teawater <teawater at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 21 Jun 2008 13:09:45 +0800
- Subject: [patch]: Fix memory leak of c-exp.y
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:
* 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);
}