Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/tui/input.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/tui/input.c b/src/tui/input.c
index d45ae0d..8ed6081 100644
--- a/src/tui/input.c
+++ b/src/tui/input.c
@@ -163,21 +163,18 @@ void tx_fillfields(struct FIELDLIST *list, int *aborted)
void tx_destroyfields(struct FIELDLIST *list)
{
- struct FIELD *ptmp;
- struct FIELD *pnext;
+ struct FIELD *ptmp = list->list;
- list->list->prevfield->nextfield = NULL;
- ptmp = list->list;
- pnext = list->list->nextfield;
+ /* break the circular list */
+ if (ptmp != NULL)
+ ptmp->prevfield->nextfield = NULL;
- do {
- free(ptmp);
+ while (ptmp != NULL) {
+ struct FIELD *pnext = ptmp->nextfield;
+ free(ptmp);
ptmp = pnext;
- if (pnext != NULL) {
- pnext = pnext->nextfield;
- }
- } while (ptmp != NULL);
+ }
del_panel(list->fieldpanel);
delwin(list->fieldwin);
--
1.9.1