From 5bc520a5cecf11e7710d74920a0e7c35bcc8f57a Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 12 Sep 2011 15:40:24 +0200 Subject: [PATCH] kill: potential null derefence [smatch scan] Signed-off-by: Karel Zak --- misc-utils/procs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/misc-utils/procs.c b/misc-utils/procs.c index 3f52387de7..1fafc9bbe4 100644 --- a/misc-utils/procs.c +++ b/misc-utils/procs.c @@ -79,11 +79,13 @@ get_pids (char *process_name, int get_all) { pids_size += 5; pids = (int *) realloc (pids, sizeof (int) * pids_size); } - pids[num_pids++] = pid; - pids[num_pids] = -1; + if (pids) { + pids[num_pids++] = pid; + pids[num_pids] = -1; + } } closedir (dir); - return (pids); + return pids; } /* -- 2.39.5