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]

Re: [commit] fix memory leak in maintenance_do_deprecate


Pedro Alves wrote:
On Sunday 27 February 2011 01:00:38, Michael Snyder wrote:
+  /* If we get here, don't leak!  */
+  if (replacement != NULL)

FYI, checks against NULL are not necessary, as xfree/free is always safe with a NULL argument. IMO, the comment adds more distraction that value, so I'd not have added it (if you see an xfree, it's obvious you're guarding against a leak).

+ xfree (replacement);


OK, as you suggest (attached, committed).



2011-03-02  Michael Snyder  <msnyder@vmware.com>

	* maint.c (maintenance_do_deprecate): No need to check for NULL.

Index: maint.c
===================================================================
RCS file: /cvs/src/src/gdb/maint.c,v
retrieving revision 1.83
diff -u -p -u -p -r1.83 maint.c
--- maint.c	27 Feb 2011 00:59:07 -0000	1.83
+++ maint.c	3 Mar 2011 01:14:09 -0000
@@ -644,9 +644,7 @@ maintenance_do_deprecate (char *text, in
       cmd->flags |= MALLOCED_REPLACEMENT;
       return;
     }
-  /* If we get here, don't leak!  */
-  if (replacement != NULL)
-    xfree (replacement);
+  xfree (replacement);
 }
 
 /* Maintenance set/show framework.  */

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