diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 4d1bc9caa..d0a680833 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -33,6 +33,7 @@ //----------------------------------------------------------------------------- LinearWorld::LinearWorld() : World() { + m_kart_display_info = NULL; } // LinearWorld // ---------------------------------------------------------------------------- @@ -82,7 +83,10 @@ void LinearWorld::init() //----------------------------------------------------------------------------- LinearWorld::~LinearWorld() { - delete[] m_kart_display_info; + // In case that a track is not found, m_kart_display info was never + // initialised. + if(m_kart_display_info) + delete[] m_kart_display_info; } // ~LinearWorld //----------------------------------------------------------------------------- diff --git a/src/modes/world.cpp b/src/modes/world.cpp index b758eaada..4f859b036 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -57,6 +57,7 @@ //----------------------------------------------------------------------------- World::World() : TimedRace() { + m_physics = NULL; } void World::init() { @@ -172,7 +173,9 @@ World::~World() { item_manager->cleanup(); delete race_state; - m_track->cleanup(); + // In case that a race is aborted (e.g. track not found) m_track is 0. + if(m_track) + m_track->cleanup(); // Clear all callbacks callback_manager->clear(CB_TRACK); @@ -181,7 +184,9 @@ World::~World() m_kart.clear(); projectile_manager->cleanup(); - delete m_physics; + // In case that the track is not found, m_physics is still undefined. + if(m_physics) + delete m_physics; sound_manager -> stopMusic();