This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] objc-lang.c (selectors_info): Check strchr for null result.
- From: Michael Snyder <msnyder at vmware dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 11 Mar 2011 13:42:28 -0800
- Subject: Re: [RFA] objc-lang.c (selectors_info): Check strchr for null result.
- References: <4D717F81.6060906@vmware.com> <20110307103837.GY30306@adacore.com>
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;