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:
parent
90b9900dc1
commit
a5ecf7e0a1
1 changed files with 4 additions and 2 deletions
6
dir.c
6
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);
|
||||
|
|
Loading…
Reference in a new issue