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]

[RFA] p-typeprint.c, move pointer use to after null-check.


If it's worth checking for null...

OK?

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

	* p-typeprint.c (pascal_type_print_method_args): Don't use 
	pointer until after null-check.

Index: p-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/p-typeprint.c,v
retrieving revision 1.38
diff -u -p -u -p -r1.38 p-typeprint.c
--- p-typeprint.c	10 Jan 2011 20:38:50 -0000	1.38
+++ p-typeprint.c	1 Mar 2011 20:34:08 -0000
@@ -156,18 +156,18 @@ void
 pascal_type_print_method_args (char *physname, char *methodname,
 			       struct ui_file *stream)
 {
-  int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
-  int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
-
-  if (is_constructor || is_destructor)
-    {
-      physname += 6;
-    }
-
   fputs_filtered (methodname, stream);
 
   if (physname && (*physname != 0))
     {
+      int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
+      int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
+
+      if (is_constructor || is_destructor)
+	{
+	  physname += 6;
+	}
+
       fputs_filtered (" (", stream);
       /* We must demangle this.  */
       while (isdigit (physname[0]))

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