This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Initialize `location' in gdbpy_decode_line


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59ecaff36145add82c315ba7a008c4a5db4a6f51

commit 59ecaff36145add82c315ba7a008c4a5db4a6f51
Author: Keith Seitz <keiths@redhat.com>
Date:   Wed Aug 12 11:31:24 2015 -0700

    Initialize `location' in gdbpy_decode_line
    
    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
     	{

Diff:
---
 gdb/ChangeLog       | 5 +++++
 gdb/python/python.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4d60123..337b9bf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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
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
 	{


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