Skip to content

Commit 660dd12

Browse files
authored
Fix freed memory access issue: A vector may be resized during use, which would invalidate all pointers into it (openscad#5270)
1 parent 392223e commit 660dd12

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/glview/cgal/CGAL_OGL_VBO_helper.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,10 @@ class VBOPolyhedron : public virtual Polyhedron
153153
}
154154

155155
static inline void CGAL_GLU_TESS_CALLBACK combineCallback(GLdouble coords[3], GLvoid *[4], GLfloat [4], GLvoid **dataOut) {
156-
static std::vector<GLdouble> vertexCache;
156+
static std::vector<std::unique_ptr<Vector3d>> vertexCache;
157157
if (dataOut) {
158-
vertexCache.push_back(coords[0]);
159-
vertexCache.push_back(coords[1]);
160-
vertexCache.push_back(coords[2]);
161-
*dataOut = &(vertexCache.back()) - 2;
158+
vertexCache.push_back(std::make_unique<Vector3d>(coords));
159+
*dataOut = vertexCache.back().get();
162160
} else {
163161
vertexCache.clear();
164162
}

0 commit comments

Comments
 (0)