Check parameters of XYToPosition() and PositionToXY() in wxSTC too

For consistency with wxTextCtrl, return -1 if input parameters are out
of range.

Closes #18430.
This commit is contained in:
Andreas Falkenhahn
2019-07-07 03:27:30 +02:00
committed by Vadim Zeitlin
parent cc41ddf62a
commit 6e556d4a71
2 changed files with 22 additions and 2 deletions

View File

@@ -5376,6 +5376,12 @@ public:
virtual long XYToPosition(long x, long y) const wxOVERRIDE
{
long pos = PositionFromLine((int)y);
if ( pos == -1 )
return -1;
if ( x >= LineLength(y) )
return -1;
pos += x;
return pos;
}
@@ -5386,8 +5392,12 @@ public:
if ( l == -1 )
return false;
int lx = pos - PositionFromLine(l);
if ( lx >= LineLength(l) )
return false;
if ( x )
*x = pos - PositionFromLine(l);
*x = lx;
if ( y )
*y = l;

View File

@@ -493,6 +493,12 @@ public:
virtual long XYToPosition(long x, long y) const wxOVERRIDE
{
long pos = PositionFromLine((int)y);
if ( pos == -1 )
return -1;
if ( x >= LineLength(y) )
return -1;
pos += x;
return pos;
}
@@ -503,8 +509,12 @@ public:
if ( l == -1 )
return false;
int lx = pos - PositionFromLine(l);
if ( lx >= LineLength(l) )
return false;
if ( x )
*x = pos - PositionFromLine(l);
*x = lx;
if ( y )
*y = l;