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]

[PATCH] Small segfault fix when there is no python


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.
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);
 	}

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