aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-10-20 19:56:05 -0500
committerRob Landley <rob@landley.net>2014-10-20 19:56:05 -0500
commit21f3c8db00f0d4a3f0989559847d2564f4c73a11 (patch)
tree50d7f1092d749394c66fe0f69bc742b8be4aecd5
parent977e48e1626b3e3f1f1f9b14f05ffc11e252455f (diff)
downloadtoybox-21f3c8db00f0d4a3f0989559847d2564f4c73a11.tar.gz
More static analysis fixes from Ashwini Sharma.
-rw-r--r--lib/xwrap.c1
-rw-r--r--toys/other/netcat.c1
-rw-r--r--toys/pending/modprobe.c12
-rw-r--r--toys/posix/nohup.c2
4 files changed, 12 insertions, 4 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index b7eb2741..6216d918 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -94,6 +94,7 @@ void xprintf(char *format, ...)
va_start(va, format);
vprintf(format, va);
+ va_end(va);
if (fflush(stdout) || ferror(stdout)) perror_exit("write");
}
diff --git a/toys/other/netcat.c b/toys/other/netcat.c
index 3c6f630b..485dda13 100644
--- a/toys/other/netcat.c
+++ b/toys/other/netcat.c
@@ -166,7 +166,6 @@ void netcat_main(void)
if (!child && toys.optc) {
int fd = pollfds[0].fd;
- if (!temp) close(sockfd);
dup2(fd, 0);
dup2(fd, 1);
if (toys.optflags&FLAG_L) dup2(fd, 2);
diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c
index cbf929b9..5431cb35 100644
--- a/toys/pending/modprobe.c
+++ b/toys/pending/modprobe.c
@@ -178,15 +178,21 @@ static int read_line(FILE *fl, char **li)
line = NULL;
linelen = nxtlinelen = 0;
len = getline(&line, (size_t*)&linelen, fl);
- if (len <= 0) return len;
+ if (len <= 0) {
+ free(line);
+ return len;
+ }
// checking for commented lines.
if (line[0] != '#') break;
free(line);
}
for (;;) {
if (line[len - 1] == '\n') len--;
- // checking line continuation.
- if (!len || line[len - 1] != '\\') break;
+ if (!len) {
+ free(line);
+ return len;
+ } else if (line[len - 1] != '\\') break;
+
len--;
nxtlen = getline(&nxtline, (size_t*)&nxtlinelen, fl);
if (nxtlen <= 0) break;
diff --git a/toys/posix/nohup.c b/toys/posix/nohup.c
index 0cece0b5..df264da2 100644
--- a/toys/posix/nohup.c
+++ b/toys/posix/nohup.c
@@ -28,8 +28,10 @@ void nohup_main(void)
S_IRUSR|S_IWUSR ))
{
char *temp = getenv("HOME");
+
temp = xmprintf("%s/%s", temp ? temp : "", "nohup.out");
xcreate(temp, O_CREAT|O_APPEND|O_WRONLY, 0600);
+ free(temp);
}
}
if (isatty(0)) {