Initialize `location' in gdbpy_decode_line
authorKeith Seitz <keiths@redhat.com>
Wed, 12 Aug 2015 18:31:24 +0000 (11:31 -0700)
committerKeith Seitz <keiths@redhat.com>
Wed, 12 Aug 2015 18:31:24 +0000 (11:31 -0700)
BuildBot flagged an uninitialized variable coming from one of the patches
in my recently committed locations/explicit patchset.

The following patch fixes this.

gdb/ChangeLog

* python/python.c (gdbpy_decode_line): Initialize `location' to NULL
and only call decode_line_1 when it is non-NULL.

diff --git a/gdb/python/python.c b/gdb/python/python.c
index c28f98b..14da62c 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -730,7 +730,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
   PyObject *result = NULL;
   PyObject *return_result = NULL;
   PyObject *unparsed = NULL;
-  struct event_location *location;
+  struct event_location *location = NULL;

   if (! PyArg_ParseTuple (args, "|s", &arg))
     return NULL;
@@ -747,7 +747,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)

   TRY
     {
-      if (arg)
+      if (location != NULL)
  sals = decode_line_1 (location, 0, 0, 0);
       else
  {

gdb/ChangeLog
gdb/python/python.c

index 4d60123197b93a67394d3c4df511182d3778d22d..337b9bf09066f59b29f10531c8b76649fa269219 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-12  Keith Seitz  <keiths@redhat.com>
+
+       * python/python.c (gdbpy_decode_line): Initialize `location' to NULL
+       and only call decode_line_1 when it is non-NULL.
+
 2015-08-12  Luis Machado  <lgustavo@codesourcery.com>
 
        * breakpoint.c (bp_loc_is_permanent): Return 0 when breakpoint
index c28f98be83db9b498e8cee964453e6b255f9661c..14da62c06d62f34ef0be44cdbde8eac92b046cbd 100644 (file)
@@ -730,7 +730,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
   PyObject *result = NULL;
   PyObject *return_result = NULL;
   PyObject *unparsed = NULL;
-  struct event_location *location;
+  struct event_location *location = NULL;
 
   if (! PyArg_ParseTuple (args, "|s", &arg))
     return NULL;
@@ -747,7 +747,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
 
   TRY
     {
-      if (arg)
+      if (location != NULL)
        sals = decode_line_1 (location, 0, 0, 0);
       else
        {
This page took 0.02972 seconds and 4 git commands to generate.