From 360416dfed47ea8de344de3798d944f270dd0aa0 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 12 May 2016 21:34:53 +0200 Subject: [PATCH] Check if path geometry contents was successfully transferred while cloning wxD2DPathData. Since only geometry with closed sink (immutable) can be transferred to another geometry object with ID2D1PathGeometry::Stream() so we have to check if actual transfer succeeded and return NULL if not. --- src/msw/graphicsd2d.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 4f92f48653..9ef769406c 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -1073,7 +1073,21 @@ wxD2DPathData::wxGraphicsObjectRefData* wxD2DPathData::Clone() const wxD2DPathData* newPathData = new wxD2DPathData(GetRenderer(), m_direct2dfactory); newPathData->EnsureGeometryOpen(); - m_pathGeometry->Stream(newPathData->m_geometrySink); + + // Only geometry with closed sink (immutable) + // can be transferred to another geometry object with + // ID2D1PathGeometry::Stream() so we have to check + // if actual transfer succeeded. + + // Transfer geometry to the new geometry sink. + HRESULT hr = m_pathGeometry->Stream(newPathData->m_geometrySink); + wxASSERT_MSG( SUCCEEDED(hr), wxS("Current geometry is in invalid state") ); + if ( FAILED(hr) ) + { + delete newPathData; + return NULL; + } + // Copy auxiliary data. newPathData->m_currentPoint = m_currentPoint; newPathData->m_transformMatrix = m_transformMatrix; newPathData->m_figureOpened = m_figureOpened;