From: Craig Small Date: Mon, 2 Mar 2020 11:08:27 +0000 (+1100) Subject: peekfd: Check return value of malloc X-Git-Tag: v23.4rc1~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=edad7cd77c5b95db2f7fe4e3678e7444a1bcc399;p=psmisc peekfd: Check return value of malloc If malloc returned null on lastbuf then we would have had a derefencing NULL issue. References: Coverity 46258 --- diff --git a/src/peekfd.c b/src/peekfd.c index f41391a..360b2f7 100644 --- a/src/peekfd.c +++ b/src/peekfd.c @@ -415,7 +415,8 @@ int main(int argc, char **argv) if (remove_duplicates) { if (lastbuf) free(lastbuf); - lastbuf = malloc(regs.REG_PARAM3); + if ( NULL == (lastbuf = malloc(regs.REG_PARAM3))) + perror("lastbuf malloc"); last_buf_size = regs.REG_PARAM3; }