OSDN Git Service

More static analysis fixes from Ashwini Sharma.
authorRob Landley <rob@landley.net>
Tue, 21 Oct 2014 00:56:05 +0000 (19:56 -0500)
committerRob Landley <rob@landley.net>
Tue, 21 Oct 2014 00:56:05 +0000 (19:56 -0500)
lib/xwrap.c
toys/other/netcat.c
toys/pending/modprobe.c
toys/posix/nohup.c

index b7eb274..6216d91 100644 (file)
@@ -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");
 }
 
index 3c6f630..485dda1 100644 (file)
@@ -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);
index cbf929b..5431cb3 100644 (file)
@@ -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;
index 0cece0b..df264da 100644 (file)
@@ -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)) {