]> granicus.if.org Git - procps-ng/commitdiff
fail on null string for arguments
authorRyan Cox <ryan_cox@byu.edu>
Tue, 29 Oct 2013 03:05:35 +0000 (21:05 -0600)
committerRyan Cox <ryan_cox@byu.edu>
Tue, 29 Oct 2013 03:05:35 +0000 (21:05 -0600)
pgrep.c

diff --git a/pgrep.c b/pgrep.c
index 6290ec5e954982fba688b3c3536178513be4aeca..38c380bd9a6b9d8cc9cc9c92ca5835ffb3710966 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -142,13 +142,19 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
 
 static struct el *split_list (const char *restrict str, int (*convert)(const char *, struct el *))
 {
-       char *copy = xstrdup (str);
-       char *ptr = copy;
+       char *copy;
+       char *ptr;
        char *sep_pos;
        int i = 0;
        int size = 0;
        struct el *list = NULL;
 
+       if (str[0] == '\0')
+               return NULL;
+
+       copy = xstrdup (str);
+       ptr = copy;
+
        do {
                if (i == size) {
                        size = size * 5 / 4 + 4;