Browse Source

Closed a memory leak in show command.

pre-master-46
pnenzi 22 years ago
parent
commit
fc1ac2dfa4
  1. 11
      ChangeLog
  2. 15
      src/frontend/device.c

11
ChangeLog

@ -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

15
src/frontend/device.c

@ -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);

Loading…
Cancel
Save