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
2
dir.c
2
dir.c
|
@ -2072,9 +2072,11 @@ join_path_from_pattern(struct glob_pattern **beg)
|
||||||
if (!path) {
|
if (!path) {
|
||||||
path_len = strlen(str);
|
path_len = strlen(str);
|
||||||
path = GLOB_ALLOC_N(char, path_len + 1);
|
path = GLOB_ALLOC_N(char, path_len + 1);
|
||||||
|
if (path) {
|
||||||
memcpy(path, str, path_len);
|
memcpy(path, str, path_len);
|
||||||
path[path_len] = '\0';
|
path[path_len] = '\0';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue