From 82ee1e028eb35f2fea31c021417923cb8b096284 Mon Sep 17 00:00:00 2001 From: liduo04 Date: Thu, 16 Nov 2017 14:51:18 +0800 Subject: [PATCH] fix fd nullptr fgets coredump --- src/process_iterator_linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/process_iterator_linux.c b/src/process_iterator_linux.c index c8cdd07a..93b44bab 100644 --- a/src/process_iterator_linux.c +++ b/src/process_iterator_linux.c @@ -98,6 +98,7 @@ static int read_process_info(pid_t pid, struct process *p) //read command line sprintf(exefile,"/proc/%d/cmdline", p->pid); fd = fopen(exefile, "r"); + if (fd==NULL) return -1; if (fgets(buffer, sizeof(buffer), fd)==NULL) { fclose(fd); return -1;