Use standard offsetof facility. Dereferencing a null pointer results

in undefined behaviour.
This commit is contained in:
Thomas Köppe authored and Zack Middleton committed 2018-01-21 06:01:50 -06:00
1 parent ed1794fe17
commit 917bca4f7d
2 files changed
+2 -1

No files matched your search

+1
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>
+1 -1
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;