]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- fix some memory leaks
authormlichvar <mlichvar>
Thu, 12 Apr 2007 17:03:57 +0000 (17:03 +0000)
committermlichvar <mlichvar>
Thu, 12 Apr 2007 17:03:57 +0000 (17:03 +0000)
checkboxtree.c
newt.spec
testtree.c
textbox.c

index 290a2e575633d037ef81cacd5b6b09dcec9ea342..e574d55e4679d50c23a65d5cf97d6c50c0763ab8 100644 (file)
@@ -531,19 +531,26 @@ static void ctDraw(newtComponent co) {
                    (*ct->currItem ? (*ct->currItem)->depth : 0) * 3 + 4);
 }
 
-static void ctDestroy(newtComponent co) {
-    struct CheckboxTree * ct = co->data;
-    struct items * item, * nextitem;
-
-    nextitem = item = ct->itemlist;
+static void destroyItems(struct items * item) {
+    struct items * nextitem;
 
     while (item != NULL) {
        nextitem = item->next;
        free(item->text);
+       if (item->branch)
+           destroyItems(item->branch);
        free(item);
        item = nextitem;
     }
+}
 
+static void ctDestroy(newtComponent co) {
+    struct CheckboxTree * ct = co->data;
+
+    destroyItems(ct->itemlist);
+    free(ct->flatList);
+    if (ct->sb)
+       ct->sb->ops->destroy(ct->sb);
     free(ct->seq);
     free(ct);
     free(co);
@@ -802,6 +809,7 @@ void newtCheckboxTreeSetCurrent(newtComponent co, void * data) {
        treeTop = item->branch;
     }
 
+    free(path);
     buildFlatList(co);
        
     item = findItem(ct->itemlist, data);
index c05ac6b700ff35dd45a6a1be2257d5a8c4bfa5ff..cf7d76a306c72af692928a59521c5592fe98fae4 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -90,6 +90,7 @@ rm -rf $RPM_BUILD_ROOT
 %changelog
 - fix cursor positioning when setting entry or checkbox flags
 - fix counting of items in checkboxtree
+- fix some memory leaks
 - fix entry scrolling (#234829)
 - fix multibyte character handling in entry
 
index 62494b8b98ea369b6c53daf54c29ab97c298cc85..8dfcca373ac30b0f5250e4b2ce62aedad29ef45b 100644 (file)
@@ -118,6 +118,8 @@ int main(void) {
        j = (int) *ptr++;
        printf("%d\n", j);
     }
+    free(result);
+
     result = newtCheckboxTreeGetMultiSelection(checktree, &numselected, 'b');
     ptr = result;
     if (!result || !numselected)
@@ -137,6 +139,7 @@ int main(void) {
     for (i = 0; list && list[i] != NEWT_ARG_LAST; i++)
         printf(" %d", list[i]);
     printf("\n");
+    free(list);
     
     newtFormDestroy(form);
     
index b2593c185885fcea6dfe1f9b712a10bd5a1158af..fcfb41f227498e30f6817c71c0f0a37226824224 100644 (file)
--- a/textbox.c
+++ b/textbox.c
@@ -451,6 +451,10 @@ static void textboxDestroy(newtComponent co) {
     int i;
     struct textbox * tb = co->data;
 
+    if (tb->sb)
+       tb->sb->ops->destroy(tb->sb);
+    if (tb->sb_act)
+       tb->sb_act->ops->destroy(tb->sb_act);
     for (i = 0; i < tb->numLines; i++) 
        free(tb->lines[i]);
     free(tb->lines);