summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dir.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index e98fa25..5221490 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);