diff options
author | Sami Kerola | 2012-10-08 09:08:19 +0200 |
---|---|---|
committer | Karel Zak | 2012-10-15 16:53:59 +0200 |
commit | 53078e08879cdef94d37128f6e99ac8e024f36fb (patch) | |
tree | 54635b7a1fef497daec64866159ab6b5273f2241 /text-utils | |
parent | more: align void in functions with prototypes, and remove void casts (diff) | |
download | kernel-qcow2-util-linux-53078e08879cdef94d37128f6e99ac8e024f36fb.tar.gz kernel-qcow2-util-linux-53078e08879cdef94d37128f6e99ac8e024f36fb.tar.xz kernel-qcow2-util-linux-53078e08879cdef94d37128f6e99ac8e024f36fb.zip |
more: remove few memory leaks
The remaining memory leaks are related to ncurses internals, or the one
open file descriptor when user users 'q' to exit.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/more.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/text-utils/more.c b/text-utils/more.c index 2ecb218f1..163f016c4 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -432,6 +432,7 @@ int main(int argc, char **argv) } } if (srchopt) { + free(previousre); previousre = xstrdup(initbuf); search(initbuf, stdin, 1); if (noscroll) @@ -454,6 +455,7 @@ int main(int argc, char **argv) if (firstf) { firstf = 0; if (srchopt) { + free(previousre); previousre = xstrdup(initbuf); search(initbuf, f, 1); if (noscroll) @@ -509,6 +511,7 @@ int main(int argc, char **argv) } free(previousre); free(initbuf); + free(Line); reset_tty(); exit(EXIT_SUCCESS); } @@ -766,6 +769,8 @@ void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__))) fflush(stdout); } else putcerr('\n'); + free(previousre); + free(Line); _exit(EXIT_SUCCESS); } @@ -1624,6 +1629,7 @@ void search(char buf[], FILE *file, register int n) } } } + regfree(&re); if (feof(file)) { if (!no_intty) { Currline = saveln; @@ -1632,9 +1638,9 @@ void search(char buf[], FILE *file, register int n) putsout(_("\nPattern not found\n")); end_it(0); } - more_error(_("Pattern not found")); free(previousre); previousre = NULL; + more_error(_("Pattern not found")); } } |