[hipl-commit] [trunk] Rev 3531: Fixed memory leak in lib/core/linkedlist.c

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 4 Feb 2010 19:16:06 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Thu Feb 04 18:13:59 2010 +0100
Revision: 3531
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Fixed memory leak in lib/core/linkedlist.c
  
  In function 'hip_ll_add' the allocated memory for 'newnode' was not freed.

Modified:
  M  lib/core/linkedlist.c

=== modified file 'lib/core/linkedlist.c'
--- lib/core/linkedlist.c       2010-01-19 09:28:42 +0000
+++ lib/core/linkedlist.c       2010-02-04 17:13:59 +0000
@@ -98,7 +98,7 @@
                                newnode->next = pointer;
                                previous->next = newnode;
                                linkedlist->element_count++;
-                               return 0;
+                               goto out;
                        }
                }
                /* The node is to be added as the last item of the list. */
@@ -107,6 +107,10 @@
                linkedlist->element_count++;
        }
 
+ out:
+       if (newnode) {
+           HIP_FREE(newnode);
+       }
        return 0;
 }

Other related posts:

  • » [hipl-commit] [trunk] Rev 3531: Fixed memory leak in lib/core/linkedlist.c - Tim Just