diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-09-25 12:46:19 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-09-25 12:46:19 (EDT) |
commit | 3423586ef2741f797c392fcf70e3f0a61cf0b220 (patch) | |
tree | 47ea165962f20a8ede3d550fa91b633ddf3e285b | |
parent | efa093e640fbf5de9c9f94955090871654cc76af (diff) | |
download | mazefight-3423586ef2741f797c392fcf70e3f0a61cf0b220.zip mazefight-3423586ef2741f797c392fcf70e3f0a61cf0b220.tar.gz mazefight-3423586ef2741f797c392fcf70e3f0a61cf0b220.tar.bz2 |
game: Fix stack use after scope
-rw-r--r-- | src/game.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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(); |