From 3423586ef2741f797c392fcf70e3f0a61cf0b220 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 25 Sep 2021 12:46:19 -0400 Subject: game: Fix stack use after scope --- (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index 6d5b573..552a606 100644 --- a/src/game.c +++ b/src/game.c @@ -50,20 +50,16 @@ _mf_game_exit(void *user_data __attribute__((__unused__))) static struct mftk_widget * _mf_game_form(SDL_Renderer *renderer, TTF_Font *text_font, - SDL_Color *text_color, struct _mf_game *game) + SDL_Color *text_color, SDL_Color *butn_color, + struct _mf_game *game) { - SDL_Color butn_color; - - butn_color.r = MF_COLOR_BUTN_R, butn_color.g = MF_COLOR_BUTN_G; - butn_color.b = MF_COLOR_BUTN_B, butn_color.a = MF_COLOR_BUTN_A; - game->timer = mftk_text_new('\0', '\0', 5, "00:00", text_font, text_color, SDL_FALSE, NULL, NULL, NULL); return mftk_grid_new(2, 1, MF_ROW_M, MF_COL_M, game->timer, MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T, mftk_button_new(text_font, "Exit", text_color, - &butn_color, MF_BTN_P, &_mf_game_exit, NULL, + butn_color, MF_BTN_P, &_mf_game_exit, NULL, renderer), MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_B ); @@ -152,6 +148,7 @@ mf_game(long seed, int size, int fow, int reveal, int enemies, TTF_Font *text_font = NULL; SDL_Color form_color; SDL_Color text_color; + SDL_Color butn_color; struct _mf_game game; struct mftk_window *win = NULL; int fr; @@ -207,13 +204,15 @@ mf_game(long seed, int size, int fow, int reveal, int enemies, form_color.b = MF_COLOR_FORM_B, form_color.a = MF_COLOR_FORM_A; text_color.r = MF_COLOR_FORE_R, text_color.g = MF_COLOR_FORE_G; text_color.b = MF_COLOR_FORE_B, text_color.a = MF_COLOR_FORE_A; + butn_color.r = MF_COLOR_BUTN_R, butn_color.g = MF_COLOR_BUTN_G; + butn_color.b = MF_COLOR_BUTN_B, butn_color.a = MF_COLOR_BUTN_A; win = mftk_window_new(MF_WINDOW_H, 0, mftk_box_new( MF_WINDOW_W - MF_WINDOW_H, MF_WINDOW_H, MF_WINDOW_W - MF_WINDOW_H, MF_WINDOW_H, MF_FORM_P, &form_color, _mf_game_form(renderer, text_font, - &text_color, &game))); + &text_color, &butn_color, &game))); game.beg = SDL_GetTicks(); -- cgit v0.9.1