Gui skins: Added memory checks and correctness

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@877 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-06-17 19:38:55 +00:00
parent 1c53b5dd7f
commit 1910a39fd4
2 changed files with 28 additions and 6 deletions

View File

@ -1278,13 +1278,28 @@ void Button_Skins(void)
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) && (clicked_button !=5) && (Key != SDLK_ESCAPE));
if(clicked_button == 1 || Key == SDLK_RETURN)
{
T_Gui_skin * gfx = (T_Gui_skin *)malloc(sizeof(T_Gui_skin));
if (gfx == NULL)
{
Error(0);
}
else
{
strcpy(skinsdir,"skins/");
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,skinsdir+6,NULL);
Load_graphics(Gfx, skinsdir);
Load_graphics(gfx, skinsdir);
if (0) // Error
{
free(gfx);
}
else
{
free(Gfx);
Gfx = gfx;
strcpy(Config_choisie.SkinFile,skinsdir+6);
}
}
// Font selection
if (Config_choisie.Font)
Menu_font=Gfx->Fun_font;

7
main.c
View File

@ -687,6 +687,13 @@ void Program_shutdown(void)
free(Spare_screen);
free(Main_screen);
// Free the skin (Gui graphics) data
if (Gfx)
{
free(Gfx);
Gfx=NULL;
}
// On prend bien soin de passer dans le répertoire initial:
if (chdir(Initial_directory)!=-1)
{