Skip to content

Commit

Permalink
Add NULL check for malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuomo Hartikainen committed Aug 21, 2014
1 parent d8516e5 commit f8fc780
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions procwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ static int parse_options (int argc, char **argv, struct options * restrict opt,
if (*tmpstr == '\0' && tmpul != 0) {
/* add PID to the list */
struct proc * proc = malloc(sizeof(struct proc));
if (proc==NULL) {
retval = E_FAIL;
go(GO_ERR, "Could not allocate memory"
"for struct proc\n");
break;
}
proc->pid = (unsigned) tmpul;
SLIST_INSERT_HEAD(proclist, proc, procs);
} else {
Expand Down

0 comments on commit f8fc780

Please sign in to comment.