mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(coverity/471380): null dereference in get_local_additions()
strrchr returns null pointer if '.' is not present in file name. Notice that filenames are filtered to match "doc/*.??[tx]" pattern earlier so we shouldn't expect null pointer here. However later in code strrchr return value is checked so it seems better and more consistent to do the same here too.
This commit is contained in:
parent
6f49ed58c3
commit
9d48266bed
@ -701,6 +701,9 @@ void get_local_additions(void)
|
|||||||
const char *const f1 = fnames[i1];
|
const char *const f1 = fnames[i1];
|
||||||
const char *const t1 = path_tail(f1);
|
const char *const t1 = path_tail(f1);
|
||||||
const char *const e1 = strrchr(t1, '.');
|
const char *const e1 = strrchr(t1, '.');
|
||||||
|
if (e1 == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (path_fnamecmp(e1, ".txt") != 0
|
if (path_fnamecmp(e1, ".txt") != 0
|
||||||
&& path_fnamecmp(e1, fname + 4) != 0) {
|
&& path_fnamecmp(e1, fname + 4) != 0) {
|
||||||
// Not .txt and not .abx, remove it.
|
// Not .txt and not .abx, remove it.
|
||||||
@ -715,7 +718,7 @@ void get_local_additions(void)
|
|||||||
}
|
}
|
||||||
const char *const t2 = path_tail(f2);
|
const char *const t2 = path_tail(f2);
|
||||||
const char *const e2 = strrchr(t2, '.');
|
const char *const e2 = strrchr(t2, '.');
|
||||||
if (e1 == NULL || e2 == NULL) {
|
if (e2 == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (e1 - f1 != e2 - f2
|
if (e1 - f1 != e2 - f2
|
||||||
|
Loading…
Reference in New Issue
Block a user