missing textures: fix double free
This commit is contained in:
parent
3052bb693a
commit
87ae1a7312
@ -68,12 +68,11 @@ static SDL_Surface *gen_missing_texture_surface(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same data is reused after being allocated/generated once */
|
/* same data is reused after being allocated/generated once */
|
||||||
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(missing_texture_data, 64, 64,
|
SDL_Surface *missing_texture_surface = SDL_CreateRGBSurfaceFrom(missing_texture_data, 64, 64,
|
||||||
3 * 8,
|
3 * 8,
|
||||||
64 * 3,
|
64 * 3,
|
||||||
rmask, gmask, bmask, 0);
|
rmask, gmask, bmask, 0);
|
||||||
|
return missing_texture_surface;
|
||||||
return surface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,7 +327,8 @@ void textures_cache_deinit(TextureCache *cache) {
|
|||||||
|
|
||||||
/* free cache hashes */
|
/* free cache hashes */
|
||||||
for (size_t i = 0; i < shlenu(cache->hash); ++i) {
|
for (size_t i = 0; i < shlenu(cache->hash); ++i) {
|
||||||
stbi_image_free(cache->hash[i].value.data->pixels);
|
if (cache->hash[i].value.data->pixels != missing_texture_data)
|
||||||
|
stbi_image_free(cache->hash[i].value.data->pixels);
|
||||||
SDL_FreeSurface(cache->hash[i].value.data);
|
SDL_FreeSurface(cache->hash[i].value.data);
|
||||||
}
|
}
|
||||||
shfree(cache->hash);
|
shfree(cache->hash);
|
||||||
|
Loading…
Reference in New Issue
Block a user