Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Small segfault fix when there is no python
@ 2014-03-20 16:33 Daniel Gutson
  2014-03-20 17:31 ` Sergio Durigan Junior
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Gutson @ 2014-03-20 16:33 UTC (permalink / raw)
  To: gdb-patches

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-22  7:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-20 16:33 [PATCH] Small segfault fix when there is no python Daniel Gutson
2014-03-20 17:31 ` Sergio Durigan Junior
2014-03-20 17:52   ` Doug Evans
2014-03-21 16:24     ` Daniel Gutson
2014-03-22  7:02       ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox