OpenToonz - An open-source full-featured 2D animation creation software
C
Fix crash when loading bad fill data (#2519)
manongjohnf2ace2130cc9
diff --git a/toonz/sources/common/tvectorimage/tcomputeregions.cpp b/toonz/sources/common/tvectorimage/tcomputeregions.cppindex f9ed60a9c..158370d27 100644--- a/toonz/sources/common/tvectorimage/tcomputeregions.cpp+++ b/toonz/sources/common/tvectorimage/tcomputeregions.cpp@@ -457,8 +457,9 @@ static void cleanNextIntersection(const VIList<Intersection> &interList,//-----------------------------------------------------------------------------void TVectorImage::Imp::eraseEdgeFromStroke(IntersectedStroke *is) {- if (is->m_edge.m_index >=- 0) // elimino il puntatore all'edge nella lista della VIStroke+ if (is->m_edge.m_index >= 0 &&+ is->m_edge.m_index < m_strokes.size()) // elimino il puntatore all'edge+ // nella lista della VIStroke{VIStroke *s;s = m_strokes[is->m_edge.m_index];@@ -602,7 +603,10 @@ void TVectorImage::Imp::doEraseIntersection(int index,p1 = p1->next();}- if (deleteIt) delete deleteIt;+ if (deleteIt) {+ m_intersectionData->m_autocloseMap.erase(index);+ delete deleteIt;+ }}//-----------------------------------------------------------------------------@@ -771,8 +775,7 @@ for (UINT ii=0; ii<branchCount; ii++)if (v[i].m_currInter >=size) // pezza per immagine corrotte...evito crash{- intList.clear();- return;+ break;}branchesBefore[v[i].m_currInter] = i;@@ -787,7 +790,7 @@ for (UINT ii=0; ii<branchCount; ii++)currBranch->m_edge.m_styleId = b.m_style;// assert(b.m_style<100);currBranch->m_edge.m_index = b.m_strokeIndex;- if (b.m_strokeIndex >= 0)+ if (b.m_strokeIndex >= 0 && b.m_strokeIndex < m_strokes.size())currBranch->m_edge.m_s = m_strokes[b.m_strokeIndex]->m_s;elsecurrBranch->m_edge.m_s = 0;@@ -840,7 +843,7 @@ assert(v[b.m_nextBranch].m_nextBranch==i);while (v[j].m_strokeIndex < 0 &&((j > 0 && v[j].m_currInter == v[j - 1].m_currInter) || j == 0))j--;- if (v[j].m_strokeIndex >= 0)+ if (v[j].m_strokeIndex >= 0 && v[j].m_strokeIndex < m_strokes.size())currInt->m_intersection =m_strokes[v[j].m_strokeIndex]->m_s->getPoint(v[j].m_w);}@@ -873,7 +876,7 @@ assert(v[b.m_nextBranch].m_nextBranch==i);if (!p2->m_edge.m_s && p2->m_edge.m_index < 0) {VIStroke *vs = m_intersectionData->m_autocloseMap[p2->m_edge.m_index];if (vs) {- p2->m_edge.m_s =+ p2->m_edge.m_s =m_intersectionData->m_autocloseMap[p2->m_edge.m_index]->m_s;// TEdge& e = it2->m_edge;@@ -3309,7 +3312,7 @@ struct TDeleteMapFunctor {};IntersectionData::~IntersectionData() {- std::for_each(m_autocloseMap.begin(), m_autocloseMap.end(),+ std::for_each(m_autocloseMap.begin(), m_autocloseMap.end(),TDeleteMapFunctor());}//-----------------------------------------------------------------------------