diff --git a/src/mission.c b/src/mission.c index 04c5e94..6868812 100644 --- a/src/mission.c +++ b/src/mission.c @@ -334,6 +334,7 @@ static void mission_freeData(MissionData* mission) { if(mission->avail.planet) free(mission->avail.planet); if(mission->avail.system) free(mission->avail.system); if(mission->avail.factions) free(mission->avail.factions); + if(mission->avail.cond) free(mission->avail.cond); memset(mission, 0, sizeof(MissionData)); } diff --git a/src/opengl.c b/src/opengl.c index f7bfda3..455b5a6 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -459,7 +459,8 @@ void gl_freeTexture(glTexture* texture) { if(cur->used <= 0) { /* Not used anymore - Free the texture. */ glDeleteTextures(1, &texture->texture); - if(texture->trans) free(texture->trans); + if(texture->trans != NULL) free(texture->trans); + if(texture->name != NULL) free(texture->name); free(texture); /* Free the list node. */ diff --git a/src/spfx.c b/src/spfx.c index 5dcb05f..7389abc 100644 --- a/src/spfx.c +++ b/src/spfx.c @@ -72,8 +72,8 @@ static int spfx_base_load(char* name, int anim, char* gfx, int sx, int sy) { } static void spfx_base_free(SPFX_Base* effect) { - if(effect->name) free(effect->name); - if(effect->gfx) gl_freeTexture(effect->gfx); + if(effect->name != NULL) free(effect->name); + if(effect->gfx != NULL) gl_freeTexture(effect->gfx); } int spfx_get(char* name) { diff --git a/src/toolkit.c b/src/toolkit.c index c65c848..c699db9 100644 --- a/src/toolkit.c +++ b/src/toolkit.c @@ -511,6 +511,7 @@ unsigned int window_create(char* name, const int x, const int y, wdw->y = SCREEN_H - windows[nwindows].h + (double)y; else wdw->y = (double)y; + /* Widgets. */ wdw->widgets = NULL; wdw->nwidgets = 0; @@ -576,6 +577,12 @@ void window_destroy(const unsigned int wid) { free(windows[i].widgets); break; } + + if(i == nwindows) { /* Not found. */ + WARN("Window of id '%u' not found in window stack!", wid); + return; + } + /* Move the other windows down a layer. */ for(; i<(nwindows-1); i++) windows[i] = windows[i+1];