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:
committed by
Vadim Zeitlin
parent
cc41ddf62a
commit
6e556d4a71
@@ -5376,6 +5376,12 @@ public:
|
|||||||
virtual long XYToPosition(long x, long y) const wxOVERRIDE
|
virtual long XYToPosition(long x, long y) const wxOVERRIDE
|
||||||
{
|
{
|
||||||
long pos = PositionFromLine((int)y);
|
long pos = PositionFromLine((int)y);
|
||||||
|
if ( pos == -1 )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ( x >= LineLength(y) )
|
||||||
|
return -1;
|
||||||
|
|
||||||
pos += x;
|
pos += x;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
@@ -5386,8 +5392,12 @@ public:
|
|||||||
if ( l == -1 )
|
if ( l == -1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
int lx = pos - PositionFromLine(l);
|
||||||
|
if ( lx >= LineLength(l) )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( x )
|
if ( x )
|
||||||
*x = pos - PositionFromLine(l);
|
*x = lx;
|
||||||
|
|
||||||
if ( y )
|
if ( y )
|
||||||
*y = l;
|
*y = l;
|
||||||
|
@@ -493,6 +493,12 @@ public:
|
|||||||
virtual long XYToPosition(long x, long y) const wxOVERRIDE
|
virtual long XYToPosition(long x, long y) const wxOVERRIDE
|
||||||
{
|
{
|
||||||
long pos = PositionFromLine((int)y);
|
long pos = PositionFromLine((int)y);
|
||||||
|
if ( pos == -1 )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ( x >= LineLength(y) )
|
||||||
|
return -1;
|
||||||
|
|
||||||
pos += x;
|
pos += x;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
@@ -503,8 +509,12 @@ public:
|
|||||||
if ( l == -1 )
|
if ( l == -1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
int lx = pos - PositionFromLine(l);
|
||||||
|
if ( lx >= LineLength(l) )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( x )
|
if ( x )
|
||||||
*x = pos - PositionFromLine(l);
|
*x = lx;
|
||||||
|
|
||||||
if ( y )
|
if ( y )
|
||||||
*y = l;
|
*y = l;
|
||||||
|
Reference in New Issue
Block a user