public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python: Fix memory allocation bug in gdbpy_read_memory.
@ 2009-04-01 18:39 bauermann
  0 siblings, 0 replies; only message in thread
From: bauermann @ 2009-04-01 18:39 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  a3f53d04c2005ca3ebe4d1f9d8a35d3b0746e01c (commit)
      from  d3c83ad5ec9f7672b87af9ad29279f459e53da11 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit a3f53d04c2005ca3ebe4d1f9d8a35d3b0746e01c
Author: Thiago Jung Bauermann <bauerman@br.ibm.com>
Date:   Wed Apr 1 15:26:15 2009 -0300

    Fix memory allocation bug in gdbpy_read_memory.
    
    	* python/python-membuf.c (gdbpy_read_memory): Allocate buffer
    	after its length has been determined.

-----------------------------------------------------------------------

Summary of changes:
 gdb/python/python-membuf.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

First 500 lines of diff:
diff --git a/gdb/python/python-membuf.c b/gdb/python/python-membuf.c
index d422d1c..d180a18 100644
--- a/gdb/python/python-membuf.c
+++ b/gdb/python/python-membuf.c
@@ -45,15 +45,12 @@ gdbpy_read_memory (PyObject *self, PyObject *args)
   void *buffer;
   membuf_object *membuf_obj;
   PyObject *addr_obj, *length_obj;
-  struct cleanup *cleanups;
+  struct cleanup *cleanups = NULL;
   volatile struct gdb_exception except;
 
   if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj))
     return NULL;
 
-  buffer = xmalloc (length);
-  cleanups = make_cleanup (xfree, buffer);
-
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
       if (!get_addr_from_python (addr_obj, &addr)
@@ -63,15 +60,15 @@ gdbpy_read_memory (PyObject *self, PyObject *args)
 	  break;
 	}
 
+      buffer = xmalloc (length);
+      cleanups = make_cleanup (xfree, buffer);
+
       read_memory (addr, buffer, length);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
 
   if (error)
-    {
-      do_cleanups (cleanups);
-      return NULL;
-    }
+    return NULL;
 
   discard_cleanups (cleanups);
 


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-01 18:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-01 18:39 [SCM] archer-tromey-python: Fix memory allocation bug in gdbpy_read_memory bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).