vim-patch:8.2.2026: Coverity warns for possibly using not NUL terminated string

Problem:    Coverity warns for possibly using not NUL terminated string.
Solution:   Put a NUL in b0_hname just in case.

e79cdb69a4

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-11-17 18:21:53 +08:00
parent 1b95eaf84b
commit 8cf38c2fd9

View File

@@ -1548,6 +1548,7 @@ static bool swapfile_unchanged(char *fname)
char hostname[B0_HNAME_SIZE]; char hostname[B0_HNAME_SIZE];
os_get_hostname(hostname, B0_HNAME_SIZE); os_get_hostname(hostname, B0_HNAME_SIZE);
hostname[B0_HNAME_SIZE - 1] = NUL; hostname[B0_HNAME_SIZE - 1] = NUL;
b0.b0_hname[B0_HNAME_SIZE - 1] = NUL; // in case of corruption
if (STRICMP(b0.b0_hname, hostname) != 0) { if (STRICMP(b0.b0_hname, hostname) != 0) {
ret = false; ret = false;
} }