Findadv: 2 more possible out of range access cases corrected

This commit is contained in:
Kornel Benko 2020-05-26 18:49:50 +02:00
parent 8dd2ac7171
commit b7cac34d96

View File

@ -2354,7 +2354,9 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
int numpars = 0;
int spaces = 0;
while (actual._tokenstart > numpars) {
if (interval_.par[pos+numpars] == ']' && interval_.par[actual._tokenstart-numpars-1] == '[')
if (pos+numpars >= interval_.par.size())
break;
else if (interval_.par[pos+numpars] == ']' && interval_.par[actual._tokenstart-numpars-1] == '[')
numpars++;
else if (interval_.par[pos+numpars] == '}' && interval_.par[actual._tokenstart-numpars-1] == '{')
numpars++;
@ -2535,7 +2537,7 @@ int LatexInfo::process(ostringstream &os, KeyInfo &actual )
if (oldStart <= end) {
processRegion(oldStart, end);
}
if (interval_.par[end] == '}') {
if (interval_.par.size() > (size_t) end && interval_.par[end] == '}') {
end += 1;
// This is the normal case.
// But if using the firstlanguage, the closing may be missing