changeset 1529:e127aa575ff2 draft

More static analysis fixes from Ashwini Sharma.
author Rob Landley <rob@landley.net>
date Mon, 20 Oct 2014 19:56:05 -0500
parents ec07449e8e4a
children 3eafa445c1a6
files lib/xwrap.c toys/other/netcat.c toys/pending/modprobe.c toys/posix/nohup.c
diffstat 4 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/xwrap.c	Mon Oct 20 19:52:29 2014 -0500
+++ b/lib/xwrap.c	Mon Oct 20 19:56:05 2014 -0500
@@ -94,6 +94,7 @@
   va_start(va, format);
 
   vprintf(format, va);
+  va_end(va);
   if (fflush(stdout) || ferror(stdout)) perror_exit("write");
 }
 
--- a/toys/other/netcat.c	Mon Oct 20 19:52:29 2014 -0500
+++ b/toys/other/netcat.c	Mon Oct 20 19:56:05 2014 -0500
@@ -166,7 +166,6 @@
           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);
--- a/toys/pending/modprobe.c	Mon Oct 20 19:52:29 2014 -0500
+++ b/toys/pending/modprobe.c	Mon Oct 20 19:56:05 2014 -0500
@@ -178,15 +178,21 @@
     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;
--- a/toys/posix/nohup.c	Mon Oct 20 19:52:29 2014 -0500
+++ b/toys/posix/nohup.c	Mon Oct 20 19:56:05 2014 -0500
@@ -28,8 +28,10 @@
         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)) {