Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch]: Fix memory leak of c-exp.y
@ 2008-06-24 12:32 teawater
  2008-06-24 14:04 ` Jan Kratochvil
  2008-06-25 13:11 ` Joel Brobecker
  0 siblings, 2 replies; 6+ messages in thread
From: teawater @ 2008-06-24 12:32 UTC (permalink / raw)
  To: gdb-patches

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);
 	}


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [patch]: Fix memory leak of c-exp.y
@ 2008-06-21 17:21 teawater
  0 siblings, 0 replies; 6+ messages in thread
From: teawater @ 2008-06-21 17:21 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: c-exp_leak.patch --]
[-- Type: text/x-diff; name=c-exp_leak.patch, Size: 805 bytes --]

--- 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);
 	}
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-25 13:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24 12:32 [patch]: Fix memory leak of c-exp.y teawater
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox