]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a safeguard to resource_used
authorMikko Rasa <tdb@tdb.fi>
Sat, 5 Sep 2015 20:04:06 +0000 (23:04 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 5 Sep 2015 20:04:06 +0000 (23:04 +0300)
It's externally accessible and someone might call it with a resource
which is not registered with that manager.

source/resourcemanager.cpp

index f008fd272c212462d6db90bdfccc020b7298015a..e989a5d07b0f5a1d3c2d148257f94694cfc7b08e 100644 (file)
@@ -120,6 +120,8 @@ bool ResourceManager::is_resource_loaded(const Resource &r) const
 void ResourceManager::resource_used(const Resource &r)
 {
        ManagedResource *managed = reinterpret_cast<ManagedResource *>(r.get_manager_data());
+       if(!managed)
+               return;
        if(managed->state==ManagedResource::NOT_LOADED && policy!=LOAD_MANUALLY)
                load_resource(*managed->resource);