From 7a9d32551ccb83d7b4f04ba76ae981527e77196e Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:43:59 -0400 Subject: [PATCH] Sanity check FPS Display to prevent crash --- src/pc/djui/djui_base.c | 1 - src/pc/djui/djui_fps_display.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pc/djui/djui_base.c b/src/pc/djui/djui_base.c index f760e6e3..2f9e7588 100644 --- a/src/pc/djui/djui_base.c +++ b/src/pc/djui/djui_base.c @@ -283,7 +283,6 @@ static void djui_base_render_border(struct DjuiBase* base) { //////////// bool djui_base_render(struct DjuiBase* base) { - if (base == NULL) { return false; } if (!base->visible) { return false; } if (base->on_render_pre != NULL) { diff --git a/src/pc/djui/djui_fps_display.c b/src/pc/djui/djui_fps_display.c index 72aa6084..84f634af 100644 --- a/src/pc/djui/djui_fps_display.c +++ b/src/pc/djui/djui_fps_display.c @@ -1,5 +1,5 @@ #include "djui.h" -#include "../pc_main.h" +#include "pc/pc_main.h" struct DjuiFpsDisplay { struct DjuiText *text; @@ -9,7 +9,7 @@ struct DjuiFpsDisplay { struct DjuiFpsDisplay *sFpsDisplay = NULL; void djui_fps_display_update(u16 fps) { - if (configShowFPS) { + if (configShowFPS && sFpsDisplay != NULL) { char fpsText[30] = ""; snprintf(fpsText, 30, "\\#dcdcdc\\FPS: \\#ffffff\\%d", fps); djui_text_set_text(sFpsDisplay->text, fpsText); @@ -17,7 +17,7 @@ void djui_fps_display_update(u16 fps) { } void djui_fps_display_render(void) { - if (configShowFPS) { + if (configShowFPS && sFpsDisplay != NULL) { djui_rect_render(&sFpsDisplay->base); djui_base_render(&sFpsDisplay->base); }