Browse Source

line_free_x(), prevent stack overflow due to non-trivial recursion

pre-master-46
rlar 13 years ago
parent
commit
6a466f7490
  1. 18
      src/frontend/inp.c

18
src/frontend/inp.c

@ -274,14 +274,16 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
void
line_free_x(struct line *deck, bool recurse)
{
if (!deck)
return;
tfree(deck->li_line);
tfree(deck->li_error);
if (recurse)
line_free(deck->li_next, TRUE);
line_free(deck->li_actual, TRUE);
tfree(deck);
while (deck) {
struct line *next_deck = deck->li_next;
line_free_x(deck->li_actual, TRUE);
tfree(deck->li_line);
tfree(deck->li_error);
tfree(deck);
if (!recurse)
return;
deck = next_deck;
}
}

Loading…
Cancel
Save