fix: use snprintf instead of sprintf

Clang 14 now reports sprintf as deprecated.
This commit is contained in:
Lewis Russell
2023-08-13 10:29:43 +01:00
committed by Lewis Russell
parent dd0e77d48a
commit a1bec02c1e
4 changed files with 15 additions and 22 deletions

View File

@@ -2350,13 +2350,13 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar
bool incll;
int searchflags = flags_arg;
pat = xmalloc(len + 7);
size_t patlen = len + 7;
pat = xmalloc(patlen);
// Put "\V" before the pattern to avoid that the special meaning of "."
// and "~" causes trouble.
assert(len <= INT_MAX);
sprintf(pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", // NOLINT(runtime/printf)
(int)len, ptr);
assert(patlen <= INT_MAX);
snprintf(pat, patlen, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", (int)len, ptr);
old_pos = curwin->w_cursor;
save_p_ws = p_ws;
save_p_scs = p_scs;