diff --git a/d3xp/Game_local.cpp b/d3xp/Game_local.cpp index e23eb57..efd8191 100644 --- a/d3xp/Game_local.cpp +++ b/d3xp/Game_local.cpp @@ -1707,7 +1707,7 @@ bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWo if ( !InhibitEntitySpawn( mapEnt->epairs ) ) { CacheDictionaryMedia( &mapEnt->epairs ); const char *classname = mapEnt->epairs.GetString( "classname" ); - if ( classname != '\0' ) { + if ( *classname != '\0' ) { FindEntityDef( classname, false ); } } @@ -2148,7 +2148,7 @@ void idGameLocal::GetShakeSounds( const idDict *dict ) { idStr soundName; soundShaderName = dict->GetString( "s_shader" ); - if ( soundShaderName != '\0' && dict->GetFloat( "s_shakes" ) != 0.0f ) { + if ( *soundShaderName != '\0' && dict->GetFloat( "s_shakes" ) != 0.0f ) { soundShader = declManager->FindSound( soundShaderName ); for ( int i = 0; i < soundShader->GetNumSounds(); i++ ) { diff --git a/d3xp/Pvs.cpp b/d3xp/Pvs.cpp index 3f97fb1..c815df3 100644 --- a/d3xp/Pvs.cpp +++ b/d3xp/Pvs.cpp @@ -875,20 +875,20 @@ idPVS::Shutdown */ void idPVS::Shutdown( void ) { if ( connectedAreas ) { - delete connectedAreas; + delete[] connectedAreas; connectedAreas = NULL; } if ( areaQueue ) { - delete areaQueue; + delete[] areaQueue; areaQueue = NULL; } if ( areaPVS ) { - delete areaPVS; + delete[] areaPVS; areaPVS = NULL; } if ( currentPVS ) { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { - delete currentPVS[i].pvs; + delete[] currentPVS[i].pvs; currentPVS[i].pvs = NULL; } } diff --git a/renderer/Image_files.cpp b/renderer/Image_files.cpp index 32cfd6d..54556a3 100644 --- a/renderer/Image_files.cpp +++ b/renderer/Image_files.cpp @@ -583,19 +583,20 @@ static void LoadTGA( const char *name, byte **pic, int *width, int *height, ID_T targa_header.colormap_type = *buf_p++; targa_header.image_type = *buf_p++; - targa_header.colormap_index = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.colormap_length = LittleShort ( *(short *)buf_p ); - buf_p += 2; + auto const get_little_short = [&buf_p]() { + short tmp; + memcpy( &tmp, buf_p, sizeof( short ) ); + short little_short = LittleShort ( tmp ); + buf_p += 2; + return little_short; + }; + targa_header.colormap_index = get_little_short(); + targa_header.colormap_length = get_little_short(); targa_header.colormap_size = *buf_p++; - targa_header.x_origin = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.y_origin = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.width = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.height = LittleShort ( *(short *)buf_p ); - buf_p += 2; + targa_header.x_origin = get_little_short(); + targa_header.y_origin = get_little_short(); + targa_header.width = get_little_short(); + targa_header.height = get_little_short(); targa_header.pixel_size = *buf_p++; targa_header.attributes = *buf_p++; diff --git a/sys/linux/main.cpp b/sys/linux/main.cpp index ad07157..02cae4e 100644 --- a/sys/linux/main.cpp +++ b/sys/linux/main.cpp @@ -144,7 +144,7 @@ const char *Sys_EXEPath( void ) { len = readlink( linkpath.c_str(), buf, sizeof( buf ) ); if ( len == -1 ) { Sys_Printf("couldn't stat exe path link %s\n", linkpath.c_str()); - buf[ len ] = '\0'; + buf[ 0 ] = '\0'; } return buf; } diff --git a/sys/linux/sound_oal.cpp b/sys/linux/sound_oal.cpp index d45a648..0bc4aca 100644 --- a/sys/linux/sound_oal.cpp +++ b/sys/linux/sound_oal.cpp @@ -42,7 +42,7 @@ public: int GetMixBufferSize( void ) { return 0; } int GetNumberOfSpeakers( void ) { - idSoundSystemLocal::s_numberOfSpeakers.GetInteger(); + return idSoundSystemLocal::s_numberOfSpeakers.GetInteger(); } // doesn't support write API @@ -97,4 +97,4 @@ idAudioHardwareLinux::Initialize */ bool idAudioHardwareLinux::Initialize( ) { return false; -} \ No newline at end of file +} diff --git a/sys/posix/posix_net.cpp b/sys/posix/posix_net.cpp index 20a2245..59ba07b 100644 --- a/sys/posix/posix_net.cpp +++ b/sys/posix/posix_net.cpp @@ -348,7 +348,9 @@ void Sys_InitNetworking(void) if ( ifr->ifr_addr.sa_family != AF_INET ) { common->Printf( "not AF_INET\n" ); } else { - ip = ntohl( *( unsigned long *)&ifr->ifr_addr.sa_data[2] ); + unsigned long raw_ip; + memcpy( &raw_ip, &ifr->ifr_addr.sa_data[2], sizeof(unsigned long) ); + ip = ntohl( raw_ip ); if ( ip == INADDR_LOOPBACK ) { common->Printf( "loopback\n" ); } else { @@ -361,7 +363,9 @@ void Sys_InitNetworking(void) if ( ioctl( s, SIOCGIFNETMASK, ifr ) < 0 ) { common->Printf( " SIOCGIFNETMASK failed: %s\n", strerror( errno ) ); } else { - mask = ntohl( *( unsigned long *)&ifr->ifr_addr.sa_data[2] ); + unsigned long raw_mask; + memcpy( &raw_mask, &ifr->ifr_addr.sa_data[2], sizeof(unsigned long) ); + mask = ntohl( raw_mask ); if ( ip != INADDR_LOOPBACK ) { common->Printf( "/%d.%d.%d.%d\n", (unsigned char)ifr->ifr_addr.sa_data[2],