Open
Description
-- test code ---
TCircle2<double> C(TPt2<double>::Origin, 5);
TTriangle2<double> tri(TPt2<double>(3,3), TVec2<double>(1,0), TVec2<double>(0,1));
double area = IntersectionArea(tri, C);
--Result(with TINTERSECTION2_DEBUG)---
Intersection triangle {3, 3),{4, 3),{3, 4) with circle {0, 0),5
nxp[i] = 1 nxp[i] = 2 nxp[i] = 1
inside = 7
nv = 7
added triangle area, now area = 0
added triangle area, now area = 0
added triangle area, now area = 0.5
s = 1.41421
added triangle area, now area = 0.547426
added triangle area, now area = 0.547426
*** stack smashing detected *** terminated
--- reason ----
The highest index for vtype and vp arrays is 5, but trying to access vtype[6] and vp[6] in the following loop (around line 258 of TIntersection2.hpp):
int vtype[6]; // 1 = triangle vertex, 0 = intersection point
pt_t vp[6];
int nv = 0; // number of actual vertices
for(int i = 0; i < 3; ++i){
if(inside & (1 << i)){
vp[nv] = seg[i][0];
vtype[nv++] = 1;
}
for(int j = 0; j < nxp[i]; ++j){
vp[nv] = xp[2*i+j];
vtype[nv++] = 0;
}
}
Metadata
Metadata
Assignees
Labels
No labels