diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-06-28 19:01:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-28 19:01:24 -0400 |
| commit | 87b42e12095aa629b0aa02f25b05cf5de5f2bbad (patch) | |
| tree | 55509215ee6a199a4ee45abe6237c00ed5f2d6ed /src/nvim/api/command.c | |
| parent | bb6576c92a44bb438733b7bdaf9f38b4caa04e51 (diff) | |
| download | rneovim-87b42e12095aa629b0aa02f25b05cf5de5f2bbad.tar.gz rneovim-87b42e12095aa629b0aa02f25b05cf5de5f2bbad.tar.bz2 rneovim-87b42e12095aa629b0aa02f25b05cf5de5f2bbad.zip | |
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.
Diffstat (limited to 'src/nvim/api/command.c')
| -rw-r--r-- | src/nvim/api/command.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index cfe87cd641..30cc88ee4a 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -463,8 +463,8 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Arena count_value = first_arg.data.integer; } else if (first_arg.type == kObjectTypeString) { // Try to parse string as a number Example: vim.api.nvim_cmd({cmd = 'copen', args = {'10'}}, {}) - char *endptr; - long val = strtol(first_arg.data.string.data, &endptr, 10); + char *endptr = first_arg.data.string.data; + long val = getdigits_long(&endptr, false, 0); // Check if entire string was consumed (valid number) and string is not empty if (*endptr == '\0' && first_arg.data.string.size > 0) { is_numeric = true; |