mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
parse_execution: Check array index before using it
This commit is contained in:
parent
7437f82d92
commit
534f694cee
1 changed files with 1 additions and 1 deletions
|
@ -1387,7 +1387,7 @@ int parse_execution_context_t::line_offset_of_character_at_offset(size_t offset)
|
|||
const wchar_t *str = pstree->src.c_str();
|
||||
if (offset > cached_lineno_offset) {
|
||||
size_t i;
|
||||
for (i = cached_lineno_offset; str[i] != L'\0' && i < offset; i++) {
|
||||
for (i = cached_lineno_offset; i < offset && str[i] != L'\0'; i++) {
|
||||
// Add one for every newline we find in the range [cached_lineno_offset, offset).
|
||||
if (str[i] == L'\n') {
|
||||
cached_lineno_count++;
|
||||
|
|
Loading…
Reference in a new issue