[En-Nut-Discussion] Memory leak in the edline (line editor) history handling

Philipp Burch phip at hb9etc.ch
Sun Nov 16 21:00:26 CET 2014


Hi folks,

the line editor edline causes memory leaks when it is closed
(EdLineClose) and the history feature is used. The problem is in
EditHistoryDestroy() (file gorp/edit/history.c):

void EditHistoryDestroy(EDITHISTORY *hist)
{
    int i;

    if (hist) {
        for (i = 0; i < hist->hist_siz; i++) {
            if (hist->hist_tab[i]) {
                free(hist->hist_tab[i]);
            }
        }
        free(hist);
    }
}

free() is called on each contained line string and on the history
structure itself, but not on the pointer table hist_tab (obtained in
EditHistoryCreate() on line 70). The patch below fixes this. It is
integrated in SVN r5893 in the devnut_tiva branch.

Cheers,
Philipp

Index: nut/gorp/edit/history.c
===================================================================
--- nut/gorp/edit/history.c	(revision 5892)
+++ nut/gorp/edit/history.c	(working copy)
@@ -94,6 +94,7 @@
                 free(hist->hist_tab[i]);
             }
         }
+        free(hist->hist_tab);
         free(hist);
     }
 }


More information about the En-Nut-Discussion mailing list