Use standard offsetof facility. Dereferencing a null pointer results

in undefined behaviour.
This commit is contained in:
Thomas Köppe 2018-01-16 16:07:48 +00:00 committed by Zack Middleton
parent ed1794fe17
commit 917bca4f7d
2 changed files with 2 additions and 1 deletions

View file

@ -160,6 +160,7 @@ typedef int intptr_t;
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>

View file

@ -330,7 +330,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int
numIndexes = LittleLong( ds->numIndexes );
// create the srfSurfaceFace_t
sfaceSize = ( size_t ) &((srfSurfaceFace_t *)0)->points[numPoints];
sfaceSize = offsetof( srfSurfaceFace_t, points ) + sizeof( *cv->points ) * numPoints;
ofsIndexes = sfaceSize;
sfaceSize += sizeof( int ) * numIndexes;