diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index be1e8138..64107c71 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -65,7 +65,7 @@ fixedWinding_t *NewFixedWinding( int points ){ Error( "NewWinding: %i points", points ); } - size = sizeof( *w ) + sizeof( *w->points ) * points; + size = offsetof( fixedWinding_t, points ) + sizeof( *w->points ) * points; w = safe_malloc( size ); memset( w, 0, size ); diff --git a/tools/quake3/q3map2/visflow.c b/tools/quake3/q3map2/visflow.c index ff390b50..2664682c 100644 --- a/tools/quake3/q3map2/visflow.c +++ b/tools/quake3/q3map2/visflow.c @@ -1423,7 +1423,7 @@ void CreatePassages( int portalnum ){ /* ydnar: prefer correctness to stack overflow */ //% memcpy( &in, p->winding, (int)((fixedWinding_t *)0)->points[p->winding->numpoints] ); if ( p->winding->numpoints <= MAX_POINTS_ON_FIXED_WINDING ) { - memcpy( &in, p->winding, sizeof( *p->winding ) + sizeof( *p->winding->points ) * p->winding->numpoints ); + memcpy( &in, p->winding, offsetof( fixedWinding_t, points ) + sizeof( *p->winding->points ) * p->winding->numpoints ); } else{ memcpy( &in, p->winding, sizeof( fixedWinding_t ) );