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

Re: [PATCH] fixed the memory leak in record.c


Hui Zhu wrote:
On Thu, Aug 27, 2009 at 13:35, Hui Zhu<teawater@gmail.com> wrote:
On Thu, Aug 27, 2009 at 11:11, Jiang Jilin<freephp@gmail.com> wrote:
* record.c (record_list_release_next) : fixed memory leak when record type is record_reg

Signed-off-by: Jiang Jilin <freephp@gmail.com>
---
 gdb/record.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gdb/record.c b/gdb/record.c
index 8afca6b..07e9e80 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -158,9 +158,10 @@ record_list_release_next (void)
    {
      rec = tmp->next;
      if (tmp->type == record_reg)
-       record_insn_num--;
-      else if (tmp->type == record_reg)
-       xfree (tmp->u.reg.val);
+       {
+         record_insn_num--;
+         xfree (tmp->u.reg.val);
+       }
      else if (tmp->type == record_mem)
       xfree (tmp->u.mem.val);
      xfree (tmp);
--
1.5.4.3



Hi Michael,


Could you please help me review this patch?

Yes, I think it looks fine. Please commit.


Following is my patch:

Cool.  Thanks for find it out.  :)
But this patch is not OK.  This record_reg should be record_end.

I make a patch for it.

Thanks,
Hui

2009-08-27 Hui Zhu <teawater@gmail.com>

       * record.c (record_list_release_next): Change the first
       record_reg to record_end.

---
 record.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/record.c
+++ b/record.c
@@ -157,7 +157,7 @@ record_list_release_next (void)
   while (tmp)
     {
       rec = tmp->next;
-      if (tmp->type == record_reg)
+      if (tmp->type == record_end)
 	record_insn_num--;
       else if (tmp->type == record_reg)
 	xfree (tmp->u.reg.val);


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