From: uis Date: Sat, 23 Dec 2023 21:26:08 +0000 (+0300) Subject: Make ubsan happy X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9015f515df58bd396a744d7817b33f42beae8ed9;p=xonotic%2Fnetradiant.git Make ubsan happy --- diff --git a/libs/picomodel/pm_md3.c b/libs/picomodel/pm_md3.c index 1b93c7b4..0540c54e 100644 --- a/libs/picomodel/pm_md3.c +++ b/libs/picomodel/pm_md3.c @@ -149,7 +149,7 @@ static int _md3_canload( PM_PARAMS_CANLOAD ){ md3 = (const md3_t*) buffer; /* check md3 magic */ - if ( *( (const int*) md3->magic ) != *( (const int*) MD3_MAGIC ) ) { + if ( memcmp( md3->magic, MD3_MAGIC, 4 ) != 0 ) { return PICO_PMV_ERROR_IDENT; } @@ -199,7 +199,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){ md3 = (md3_t*) bb; /* check ident and version */ - if ( *( (int*) md3->magic ) != *( (int*) MD3_MAGIC ) || _pico_little_long( md3->version ) != MD3_VERSION ) { + if ( memcmp( md3->magic, MD3_MAGIC, 4 ) != 0 || _pico_little_long( md3->version ) != MD3_VERSION ) { /* not an md3 file (todo: set error) */ _pico_free( bb0 ); return NULL; diff --git a/tools/quake3/q3map2/bspfile_ibsp.c b/tools/quake3/q3map2/bspfile_ibsp.c index 433d4457..d4c7e1cf 100644 --- a/tools/quake3/q3map2/bspfile_ibsp.c +++ b/tools/quake3/q3map2/bspfile_ibsp.c @@ -459,7 +459,7 @@ void LoadIBSPFile( const char *filename ){ SwapBlock( (int*) ( (byte*) header + sizeof( int ) ), sizeof( *header ) - sizeof( int ) ); /* make sure it matches the format we're trying to load */ - if ( force == qfalse && *( (int*) header->ident ) != *( (int*) game->bspIdent ) ) { + if ( force == qfalse && memcmp( header->ident, game->bspIdent, 4 ) != 0 ) { Error( "%s is not a %s file", filename, game->bspIdent ); } if ( force == qfalse && header->version != game->bspVersion ) { @@ -568,7 +568,7 @@ void WriteIBSPFile( const char *filename ){ //% Swapfile(); /* set up header */ - *( (int*) (bspHeader_t*) header->ident ) = *( (int*) game->bspIdent ); + memcpy(header->ident, game->bspIdent, 4); header->version = LittleLong( game->bspVersion ); /* write initial header */ @@ -577,7 +577,7 @@ void WriteIBSPFile( const char *filename ){ /* add marker lump */ const char marker[] = "I LOVE MY Q3MAP2"; - AddLump( file, header, 0, marker, strlen( marker ) + 1 ); + AddLump( file, (bspHeader_t*) header, 0, marker, strlen( marker ) + 1 ); /* add lumps */ AddLump( file, (bspHeader_t*) header, LUMP_SHADERS, bspShaders, numBSPShaders * sizeof( bspShader_t ) ); diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index cff40a85..26b2a347 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1874,11 +1874,12 @@ void SetupGrid( void ){ /* clear lightgrid */ for ( i = 0; i < numRawGridPoints; i++ ) { - VectorCopy( ambientColor, rawGridPoints[ i ].ambient[ j ] ); + VectorCopy( ambientColor, rawGridPoints[ i ].ambient[ 0 ] ); rawGridPoints[ i ].styles[ 0 ] = LS_NORMAL; bspGridPoints[ i ].styles[ 0 ] = LS_NORMAL; for ( j = 1; j < MAX_LIGHTMAPS; j++ ) { + VectorCopy( ambientColor, rawGridPoints[ i ].ambient[ j ] ); rawGridPoints[ i ].styles[ j ] = LS_NONE; bspGridPoints[ i ].styles[ j ] = LS_NONE; }