This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]