1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Yusuke Endoh 2019-10-13 00:51:50 +09:00
parent 90b9900dc1
commit a5ecf7e0a1

6
dir.c
View file

@ -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);