From 9610dbd2108e62f83f5bee3d6ea55fcac5d39e0a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 9 Feb 2016 10:31:46 +0000 Subject: remove possible null dereference on allocation faliure fix null dereference is calloc fails. coverity 1316339 --- utils/filepath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/filepath.c b/utils/filepath.c index 87f9302f4..9368c216c 100644 --- a/utils/filepath.c +++ b/utils/filepath.c @@ -181,7 +181,8 @@ filepath_generate(char * const *pathv, const char * const *langv) respath = calloc(MAX_RESPATH, sizeof(char *)); - while (pathv[pathc] != NULL) { + while ((respath != NULL) && + (pathv[pathc] != NULL)) { if ((stat(pathv[pathc], &dstat) == 0) && S_ISDIR(dstat.st_mode)) { /* path element exists and is a directory */ @@ -199,7 +200,6 @@ filepath_generate(char * const *pathv, const char * const *langv) } pathc++; } - return respath; } -- cgit v1.2.3