Check that number of points passed to wxDC::DrawSpline() is at least 2
DoDrawSpline() implementations for all ports work for the number of points >= 2 (for 2 points there is drawn a straight line) so we need to add checks whether this requirement is met. See #19172.
This commit is contained in:
@@ -714,7 +714,7 @@ public:
|
||||
/**
|
||||
Draws a spline between all given points using the current pen.
|
||||
|
||||
The number of points must be at least 3 for the spline to be drawn.
|
||||
The number of points must be at least 2 for the spline to be drawn.
|
||||
|
||||
@beginWxPerlOnly
|
||||
Not supported by wxPerl.
|
||||
|
@@ -903,16 +903,14 @@ static void wx_spline_draw_point_array(wxDC *dc)
|
||||
void wxDCImpl::DoDrawSpline( const wxPointList *points )
|
||||
{
|
||||
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
|
||||
wxCHECK_RET(points, "NULL pointer to spline points?");
|
||||
wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?");
|
||||
|
||||
const wxPoint *p;
|
||||
double cx1, cy1, cx2, cy2;
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
wxPointList::compatibility_iterator node = points->GetFirst();
|
||||
if (!node)
|
||||
// empty list
|
||||
return;
|
||||
|
||||
p = node->GetData();
|
||||
|
||||
x1 = p->x;
|
||||
|
@@ -846,6 +846,8 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],
|
||||
void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
{
|
||||
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
|
||||
wxCHECK_RET(points, "NULL pointer to spline points?");
|
||||
wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?");
|
||||
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
@@ -853,10 +855,6 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
wxGraphicsPath path = m_graphicContext->CreatePath();
|
||||
|
||||
wxPointList::compatibility_iterator node = points->GetFirst();
|
||||
if ( !node )
|
||||
// empty list
|
||||
return;
|
||||
|
||||
const wxPoint *p = node->GetData();
|
||||
|
||||
wxCoord x1 = p->x;
|
||||
|
@@ -1463,6 +1463,8 @@ void wxPostScriptDCImpl::SetLogicalFunction(wxRasterOperationMode WXUNUSED(funct
|
||||
void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points )
|
||||
{
|
||||
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
|
||||
wxCHECK_RET(points, "NULL pointer to spline points?");
|
||||
wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?");
|
||||
|
||||
SetPen( m_pen );
|
||||
|
||||
|
@@ -1716,6 +1716,9 @@ void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCo
|
||||
#if wxUSE_SPLINES
|
||||
void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
{
|
||||
wxCHECK_RET(points, "NULL pointer to spline points?");
|
||||
wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?");
|
||||
|
||||
SetPen (m_pen);
|
||||
|
||||
double c, d, x1, y1, x3, y3;
|
||||
|
@@ -1158,10 +1158,10 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
// B2 = (2*P1 + P2)/3
|
||||
// B3 = P2
|
||||
|
||||
wxASSERT_MSG( points, wxT("NULL pointer to spline points?") );
|
||||
wxCHECK_RET( points, "NULL pointer to spline points?" );
|
||||
|
||||
const size_t n_points = points->GetCount();
|
||||
wxASSERT_MSG( n_points > 2 , wxT("incomplete list of spline points?") );
|
||||
wxCHECK_RET( n_points >= 2 , "incomplete list of spline points?" );
|
||||
|
||||
const size_t n_bezier_points = n_points * 3 + 1;
|
||||
POINT *lppt = new POINT[n_bezier_points];
|
||||
|
Reference in New Issue
Block a user