From 534f694ceedd9bb8f1d9190c4a1fbc7736bb1d77 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 14 Nov 2018 11:24:55 +0100 Subject: [PATCH] parse_execution: Check array index before using it --- src/parse_execution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index e0c17d223..304f2a3f8 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -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++;