From a5ecf7e0a165dff1b4604f1ed75a677c690488df Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 13 Oct 2019 00:51:50 +0900 Subject: dir.c (join_path_from_pattern): check NULL from malloc Coverity Scan points out that all the return values of GLOB_ALLOC_N are NULL-checked except this call. --- dir.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index e98fa25278..5221490b44 100644 --- a/dir.c +++ b/dir.c @@ -2072,8 +2072,10 @@ join_path_from_pattern(struct glob_pattern **beg) if (!path) { path_len = strlen(str); path = GLOB_ALLOC_N(char, path_len + 1); - memcpy(path, str, path_len); - path[path_len] = '\0'; + if (path) { + memcpy(path, str, path_len); + path[path_len] = '\0'; + } } else { size_t len = strlen(str); -- cgit v1.2.3