st-texture-cache: Don't add NULL textures to cache

This might cause a crash when cleaning up the cache as the hash table has
cogl_object_unref as DestroyNotify function but that assumes that
the passed object is a valid CoglObject.

Fixes: #210


(cherry picked from commit a24999b7a3)
This commit is contained in:
Marco Trevisan (Treviño) 2018-04-17 04:43:34 -05:00 committed by Marco Trevisan
parent 4ff7e84c51
commit 2c617e5a3a

View File

@ -520,6 +520,8 @@ finish_texture_load (AsyncTextureLoadData *data,
goto out; goto out;
texdata = pixbuf_to_cogl_texture (pixbuf); texdata = pixbuf_to_cogl_texture (pixbuf);
if (!texdata)
goto out;
if (data->policy != ST_TEXTURE_CACHE_POLICY_NONE) if (data->policy != ST_TEXTURE_CACHE_POLICY_NONE)
{ {
@ -1273,6 +1275,9 @@ st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache,
texdata = pixbuf_to_cogl_texture (pixbuf); texdata = pixbuf_to_cogl_texture (pixbuf);
g_object_unref (pixbuf); g_object_unref (pixbuf);
if (!texdata)
goto out;
if (policy == ST_TEXTURE_CACHE_POLICY_FOREVER) if (policy == ST_TEXTURE_CACHE_POLICY_FOREVER)
{ {
cogl_object_ref (texdata); cogl_object_ref (texdata);