aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-09-27 15:54:41 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-09-27 15:54:41 -0700
commit0b821ec893407500011430a94387d90a85acbb46 (patch)
tree2ddd370d0b03f5c8d091d90cae696f2eb1e5ecec
parentebeb6a63f382b955af72375aa1e4abe3f988df5b (diff)
downloadtftp-hpa-0b821ec893407500011430a94387d90a85acbb46.tar.gz
Fix double-free error in tftp client.
-rw-r--r--tftp/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tftp/main.c b/tftp/main.c
index 961c0c4..9db1c87 100644
--- a/tftp/main.c
+++ b/tftp/main.c
@@ -304,8 +304,6 @@ main(int argc, char *argv[])
(*c->handler)(pargc, pargv);
exit(0);
}
- if (sigsetjmp(toplevel,1) != 0)
- (void)putchar('\n');
#ifdef WITH_READLINE
#ifdef HAVE_READLINE_HISTORY_H
@@ -313,6 +311,8 @@ main(int argc, char *argv[])
#endif
#endif
+ if (sigsetjmp(toplevel,1) != 0)
+ (void)putchar('\n');
command();
return 0; /* Never reached */
@@ -336,8 +336,10 @@ getmoreargs(const char *partial, const char *mprompt)
elen = strlen(eline);
- if (line)
+ if (line) {
free(line);
+ line = NULL;
+ }
line = xmalloc(len+elen+1);
strcpy(line, partial);
strcpy(line+len, eline);
@@ -734,8 +736,10 @@ command(void)
for (;;) {
#ifdef WITH_READLINE
- if ( line )
+ if ( line ) {
free(line);
+ line = NULL;
+ }
line = readline(prompt);
if ( !line )
exit(0); /* EOF */