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: [RFA] objc-lang.c (selectors_info): Check strchr for null result.


Joel Brobecker wrote:
2011-03-04 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>

* objc-lang.c (selectors_info): Check strchr for null result.

Another one where I'm not a specialist of the code, but I think I get the intent of the code.

/* Find selector part. */
name = (char *) strchr(name+2, ' ');
+ if (name == NULL)
+ internal_error (__FILE__, __LINE__, + _("Bad method name '%s'"), + SYMBOL_NATURAL_NAME (msymbol));

I think that the right thing to do, in this case, is to emit a complaint. The most probable way to trigger this problem is by reading some invalid debugging information, and an internal-error in this case would be mis-leading. And we can also recover nicely from it by simply ignoring the symbol.


Thanks. How about this?



2011-03-04  Michael Snyder  <msnyder@msnyder-server.eng.vmware.com>

	* objc-lang.c (selectors_info): Check strchr for null result.

Index: objc-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/objc-lang.c,v
retrieving revision 1.96
diff -u -p -r1.96 objc-lang.c
--- objc-lang.c	7 Mar 2011 10:41:34 -0000	1.96
+++ objc-lang.c	11 Mar 2011 21:42:02 -0000
@@ -752,6 +752,13 @@ selectors_info (char *regexp, int from_t
 	    continue;
 	  /* Find selector part.  */
 	  name = (char *) strchr (name+2, ' ');
+	  if (name == NULL)
+	    {
+	      complaint (&symfile_complaints, 
+			 _("Bad method name '%s'"), 
+			 SYMBOL_NATURAL_NAME (msymbol));
+	      continue;
+	    }
 	  if (regexp == NULL || re_exec(++name) != 0)
 	    { 
 	      char *mystart = name;

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