Closed a memory leak in show command.

This commit is contained in:
pnenzi 2004-08-13 10:11:06 +00:00
parent 1c9082a4e3
commit fc1ac2dfa4
2 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2004-08-13 Paolo Nenzi <p.nenzi@ieee.org>
* src/frontend/device.c: "show" command leaked 28 bytes for each
group of words since an allocated pointer in line 33 of gens.c
was never freed. It is not possible to free allocated memory
using that pointer since it is used and its value altered. I
used "listdg" copying original pointer value to it and freeing
memory using "listdg" instead. There were sone "tfree" that
caused problems for incorrect inputs, I have removed them and
tested against some bad syntax. Results shows no leaks.
2004-08-09 Paolo Nenzi <p.nenzi@ieee.org>
* Updated and corrected test files in "tests" directory. Added

View File

@ -60,7 +60,7 @@ all_show(wordlist *wl, int mode)
wordlist *params, *nextgroup, *thisgroup;
wordlist *prev, *next, *w;
int screen_width;
dgen *dg, *listdg;
dgen *dg, *listdg = NULL;
int instances;
int i, j, n;
int param_flag, dev_flag;
@ -124,12 +124,16 @@ all_show(wordlist *wl, int mode)
else
thisgroup = next;
}
/*
tfree(w->wl_word);
tfree(w);
*/
w = NULL;
} else if (eq(w->wl_word, ":")) {
/*
tfree(w->wl_word);
tfree(w);
*/
w = NULL;
if (!params) {
params = next;
@ -145,8 +149,10 @@ all_show(wordlist *wl, int mode)
}
} else if (eq(w->wl_word, ";") || eq(w->wl_word, ",")) {
nextgroup = next;
/*
tfree(w->wl_word);
tfree(w);
*/
w = NULL;
if (prev)
prev->wl_next = NULL;
@ -217,7 +223,12 @@ all_show(wordlist *wl, int mode)
printf("\n");
}
}
/* Paolo Nenzi 2004:
* This tfree is necessary to free memory allocated by NEW in
* dgen_init. It is not possible to free dg since it is casted
* to NULL from dgen_next and is lost.
*/
tfree(listdg);
wl = nextgroup;
} while (wl);