fix double freeing of furi string

flagsbased-uncover
Felix Pankratz 2 years ago
parent 5f23b4ba0f
commit a9d6011f5e

@ -79,12 +79,15 @@ static void render_callback(Canvas* const canvas, void* ctx) {
if (minesweeper_state == NULL) { if (minesweeper_state == NULL) {
return; return;
} }
FuriString* tempStr; FuriString* mineStr;
tempStr = furi_string_alloc(); FuriString* timeStr;
furi_string_printf(tempStr, "Mines: %d", MINECOUNT - minesweeper_state->flags_set); mineStr = furi_string_alloc();
timeStr = furi_string_alloc();
furi_string_printf(mineStr, "Mines: %d", MINECOUNT - minesweeper_state->flags_set);
canvas_set_font(canvas, FontSecondary); canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, furi_string_get_cstr(tempStr)); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, furi_string_get_cstr(mineStr));
furi_string_free(tempStr);
int seconds = 0; int seconds = 0;
int minutes = 0; int minutes = 0;
if (minesweeper_state->game_started) { if (minesweeper_state->game_started) {
@ -93,9 +96,8 @@ static void render_callback(Canvas* const canvas, void* ctx) {
minutes = (int) seconds / 60; minutes = (int) seconds / 60;
seconds = seconds % 60; seconds = seconds % 60;
} }
furi_string_printf(tempStr, "%01d:%02d", minutes, seconds); furi_string_printf(timeStr, "%01d:%02d", minutes, seconds);
canvas_draw_str_aligned(canvas, 128, 0, AlignRight, AlignTop, furi_string_get_cstr(tempStr)); canvas_draw_str_aligned(canvas, 128, 0, AlignRight, AlignTop, furi_string_get_cstr(timeStr));
furi_string_free(tempStr);
for (int y = 0; y < PLAYFIELD_HEIGHT; y++) { for (int y = 0; y < PLAYFIELD_HEIGHT; y++) {
for (int x = 0; x < PLAYFIELD_WIDTH; x++) { for (int x = 0; x < PLAYFIELD_WIDTH; x++) {
@ -217,7 +219,9 @@ static void render_callback(Canvas* const canvas, void* ctx) {
} }
} }
} }
furi_string_free(tempStr);
furi_string_free(mineStr);
furi_string_free(timeStr);
release_mutex((ValueMutex*)ctx, minesweeper_state); release_mutex((ValueMutex*)ctx, minesweeper_state);
} }

Loading…
Cancel
Save