Message ID | 874m47nlwf.fsf@redhat.com |
---|---|
State | New |
Headers | show |
On 10/20/2016 08:19 AM, Nick Clifton wrote: > Hi Guys, > > Whilst experimenting with writing a plugin for gcc I discovered that > I could cause a segfault if I attempted to register a PLUGIN_INFO > callback with any name other than the name of the plugin. The > attached patch fixes this problem and produces an error message > instead. > > OK to apply ? > > Cheers > Nick > > gcc/ChangeLog > 2016-10-20 Nick Clifton <nickc@redhat.com> > > * plugin.c (register_plugin_info): Produce an error message if the > plugin is not found in the hash table. OK. jeff
Index: gcc/plugin.c =================================================================== --- gcc/plugin.c (revision 241361) +++ gcc/plugin.c (working copy) @@ -330,7 +330,15 @@ register_plugin_info (const char* name, struct plugin_info *info) { void **slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT); - struct plugin_name_args *plugin = (struct plugin_name_args *) *slot; + struct plugin_name_args *plugin; + + if (slot == NULL) + { + error ("unable to register info for plugin '%s' - plugin name not found", + name); + return; + } + plugin = (struct plugin_name_args *) *slot; plugin->version = info->version; plugin->help = info->help; }