This is the mail archive of the
archer-commits@sourceware.org
mailing list for the Archer project.
[SCM] archer-tromey-python: Fix memory allocation bug in gdbpy_read_memory.
- From: bauermann at sourceware dot org
- To: archer-commits at sourceware dot org
- Date: 1 Apr 2009 18:39:05 -0000
- Subject: [SCM] archer-tromey-python: Fix memory allocation bug in gdbpy_read_memory.
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.