mirror of
https://github.com/neovim/neovim.git
synced 2026-08-27 09:31:47 +00:00
build: lint "strtol" #40442
Problem: No lint for strtol(). Solution: Add lint, and update existing usages. Callers that previously got a (garbage) large positive value: - `indent.c`: use getdigits() (intmax, no int truncation) with def=1 so overflow/too-large values stay positive and fall through to the existing "too big" check (E475). - `file_search.c`: use getdigits() with def=255 so overflow/too-large values keep the "max expand" (else) branch. The other conversions (api/command.c, eval/window.c, highlight_group.c, tui/tui.c) only diverge on pathological overflow inputs where strtol's result was already garbage and the observable outcome is unchanged.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "nvim/ascii_defs.h"
|
||||
#include "nvim/autocmd.h"
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/cursor.h"
|
||||
#include "nvim/errors.h"
|
||||
#include "nvim/eval/funcs.h"
|
||||
@@ -277,8 +278,8 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar)
|
||||
}
|
||||
} else {
|
||||
// Extract the window count (if specified). e.g. winnr('3j')
|
||||
char *endp;
|
||||
int count = (int)strtol(arg, &endp, 10);
|
||||
char *endp = (char *)arg;
|
||||
int count = getdigits_int(&endp, false, 0);
|
||||
if (count <= 0) {
|
||||
// if count is not specified, default to 1
|
||||
count = 1;
|
||||
|
||||
Reference in New Issue
Block a user