Fix return value of search_find_text() when the match is out of bounds
When performing a regular expression search on a range, and there is a match past the end of the range, search_find_text() used to improperly return the position of the match, but without filling the Sci_TextToFind structure. This lead to the calling code assume there was a match, and maybe read the uninitialized fields in the Sci_TextToFind structure, thus leading to undefined behavior. So, fix search_find_text() so it properly returns -1 when there is a match but it is outside the bounds.
This commit is contained in:
parent
89d6b42503
commit
83e7afc199
@ -1989,7 +1989,9 @@ gint search_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *t
|
||||
pos = ttf->chrg.cpMin;
|
||||
ret = find_regex(sci, pos, regex);
|
||||
|
||||
if (ret >= 0 && ret < ttf->chrg.cpMax)
|
||||
if (ret >= ttf->chrg.cpMax)
|
||||
ret = -1;
|
||||
else if (ret >= 0)
|
||||
{
|
||||
ttf->chrgText.cpMin = regex_matches[0].start;
|
||||
ttf->chrgText.cpMax = regex_matches[0].end;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user