]> granicus.if.org Git - psmisc/commitdiff
Removed early free on name_len
authorCraig Small <csmall@enc.com.au>
Mon, 22 Dec 2014 21:58:47 +0000 (08:58 +1100)
committerCraig Small <csmall@enc.com.au>
Mon, 22 Dec 2014 21:58:47 +0000 (08:58 +1100)
name_len was being freed too early and in a loop so
sometimes you would hit a double-free problem
The locale changes were to keep efence happy though
i suspect something strange was going on with locales there
too.

src/killall.c

index 1b8e87870ab47479e2eddf3853cdd9b646a88968..f8616495069d7763336e6576b47d5d8b18f92ab2 100644 (file)
@@ -131,8 +131,7 @@ uptime()
       fprintf(stderr, "killall: error opening uptime file\n"); 
       exit(1);
    }
-   savelocale = setlocale(LC_NUMERIC, NULL);
-   setlocale(LC_NUMERIC,"C");
+   savelocale = setlocale(LC_NUMERIC,"C");
    if (fscanf(file, "%2047s", buf) == EOF) perror("uptime");
    fclose(file);
    setlocale(LC_NUMERIC,savelocale);
@@ -528,7 +527,6 @@ kill_all (int signal, int names, char **namelist, struct passwd *pwent)
          found_name = j;
          break;
        }  
-        free(name_len);
         
         if (names && found_name==-1)
          continue;  /* match by process name faild */
@@ -571,6 +569,7 @@ kill_all (int signal, int names, char **namelist, struct passwd *pwent)
     }
   free(reglist);
   free(pgids);
+  free(name_len);
   if (!quiet)
     for (i = 0; i < names; i++)
       if (!(found & (1 << i)))