commit 11d2d1faaf9cd0e2b6796c17390137dedcdc90bb
Author:     sin <s...@2f30.org>
AuthorDate: Sat Jun 30 17:31:53 2018 +0100
Commit:     sin <s...@2f30.org>
CommitDate: Sat Jun 30 17:31:53 2018 +0100

    Fix segfault in killall5 without -o
    
    Original patch by Platon Ryzhikov <ihumme...@yandex.ru>

diff --git a/killall5.c b/killall5.c
index 14790b9..f3541f5 100644
--- a/killall5.c
+++ b/killall5.c
@@ -73,10 +73,12 @@ main(int argc, char *argv[])
 
        SLIST_INIT(&omitpid_head);
 
-       for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) {
-               pe = emalloc(sizeof(*pe));
-               pe->pid = estrtol(p, 10);
-               SLIST_INSERT_HEAD(&omitpid_head, pe, entry);
+       if (oflag) {
+               for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) {
+                       pe = emalloc(sizeof(*pe));
+                       pe->pid = estrtol(p, 10);
+                       SLIST_INSERT_HEAD(&omitpid_head, pe, entry);
+               }
        }
 
        if (sig != SIGSTOP && sig != SIGCONT)

Reply via email to