[PATCH] Small segfault fix when there is no python

Daniel Gutson
2014-03-20T16:33:31Z

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

Hi,

the small attached patch prevents gdb to segfault when an extension
language definition has no ops,
which e.g. occurs when HAVE_PYTHON is not defined so
extension_language_python remains with ops in NULL.
This causes the line
if (extlang->ops->eval_from_control_command != NULL)
(in eval_ext_lang_from_control_command) to dereference a null pointer.

Please commit it for me if approved since I don't have write access.

Thanks,

Daniel.

2014-03-20 Daniel Gutson (daniel.gutson@tallertechnologies.com)

gdb/
* extension.c: (eval_ext_lang_from_control_command) Added check to
prevent dereference of null pointer.

[-- Attachment #2: python.patch --]
[-- Type: text/x-patch, Size: 768 bytes --]

diff --git a/gdb/extension.c b/gdb/extension.c
index c2f502b..8357ee8 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -342,11 +342,14 @@ eval_ext_lang_from_control_command (struct command_line *cmd)
{
if (extlang->cli_control_type == cmd->control_type)
{
- if (extlang->ops->eval_from_control_command != NULL)
- {
- extlang->ops->eval_from_control_command (extlang, cmd);
- return;
- }
+ if (extlang->ops != NULL)
+ {
+ if (extlang->ops->eval_from_control_command != NULL)
+ {
+ extlang->ops->eval_from_control_command (extlang, cmd);
+ return;
+ }
+ }
/* The requested extension language is not supported in this GDB. */
throw_ext_lang_unsupported (extlang);
}