From c1b32892190ee0b605cac5087fb000f6cefc4b1e Mon Sep 17 00:00:00 2001 From: Michael McConville Date: Sat, 2 Jan 2016 12:20:40 -0500 Subject: [PATCH] Check for allocation failure Pointed out by Michael Reed. --- openbsd/OpenBSDProcessList.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c index aa765a15..d6420853 100644 --- a/openbsd/OpenBSDProcessList.c +++ b/openbsd/OpenBSDProcessList.c @@ -139,7 +139,8 @@ char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, in for (i = 0; arg[i] != NULL; i++) { len += strlen(arg[i]) + 1; } - buf = s = malloc(len); + if ((buf = s = malloc(len)) == NULL) + err(1, NULL); for (i = 0; arg[i] != NULL; i++) { n = strlcpy(buf, arg[i], (s + len) - buf); buf += n;