public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: bauermann@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-tromey-python: Fix memory allocation bug in gdbpy_read_memory.
Date: Wed, 01 Apr 2009 18:39:00 -0000	[thread overview]
Message-ID: <20090401183905.12706.qmail@sourceware.org> (raw)

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.


                 reply	other threads:[~2009-04-01 18:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090401183905.12706.qmail@sourceware.org \
    --to=bauermann@sourceware.org \
    --cc=archer-commits@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).