diff --git a/sdlpp.hpp b/sdlpp.hpp index a17596d..8b196b5 100644 --- a/sdlpp.hpp +++ b/sdlpp.hpp @@ -533,7 +533,8 @@ public: std::vector< std::shared_ptr< RenderObject > > getObjects(const std::unordered_set< int > &objectIDs) { std::vector< std::shared_ptr< RenderObject > > ret{}; for ( const auto &x : render_objects ) { - if ( objectIDs.find( x->getId() ) != objectIDs.end() ) { + // check if object exists because of possible race condition + if ( x && objectIDs.find( x->getId() ) != objectIDs.end() ) { ret.push_back( x ); } }