mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-26 11:21:08 +00:00
[q3map2/{vis,visflow}.c] Reinstate offsetof-based size computation.
The logic isn't entirely legitimate, since fixedWinding_t is a fixed-size type that is *sometimes* treated as a variable-sized type, but it would require deeper refactoring to make this strictly conforming. As it is, we just keep the offset computation as a reasonable way to calculate the allocation size. Fixes #583.
This commit is contained in:
parent
f00e8fd6a6
commit
d3d00345c5
2 changed files with 2 additions and 2 deletions
|
@ -65,7 +65,7 @@ fixedWinding_t *NewFixedWinding( int points ){
|
||||||
Error( "NewWinding: %i points", 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 );
|
w = safe_malloc( size );
|
||||||
memset( w, 0, size );
|
memset( w, 0, size );
|
||||||
|
|
||||||
|
|
|
@ -1423,7 +1423,7 @@ void CreatePassages( int portalnum ){
|
||||||
/* ydnar: prefer correctness to stack overflow */
|
/* ydnar: prefer correctness to stack overflow */
|
||||||
//% memcpy( &in, p->winding, (int)((fixedWinding_t *)0)->points[p->winding->numpoints] );
|
//% memcpy( &in, p->winding, (int)((fixedWinding_t *)0)->points[p->winding->numpoints] );
|
||||||
if ( p->winding->numpoints <= MAX_POINTS_ON_FIXED_WINDING ) {
|
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{
|
else{
|
||||||
memcpy( &in, p->winding, sizeof( fixedWinding_t ) );
|
memcpy( &in, p->winding, sizeof( fixedWinding_t ) );
|
||||||
|
|
Loading…
Reference in a new issue