Fix crash on input box (#1043)

When typing ` into the coopnet password inputbox (the same as the console bind)
It would do all of the null checks, then open the console changing the focus,
then call a null function because the null checks are no longer valid.

So I moved the null checks to where they're needed.

Co-authored-by: MysterD <myster@d>
This commit is contained in:
djoslin0 2025-11-29 04:15:46 -08:00 committed by GitHub
parent 4ce9be4935
commit a1b178fb64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -279,10 +279,6 @@ bool djui_interactable_on_key_down(int scancode) {
void djui_interactable_on_key_up(int scancode) {
bool keyFocused = (gInteractableFocus != NULL)
&& (gInteractableFocus->interactable != NULL)
&& (gInteractableFocus->interactable->on_key_up != NULL);
if (!gDjuiChatBoxFocus) {
for (int i = 0; i < MAX_BINDS; i++) {
if (scancode == (int)configKeyConsole[i]) { djui_console_toggle(); break; }
@ -304,6 +300,10 @@ void djui_interactable_on_key_up(int scancode) {
}
}
bool keyFocused = (gInteractableFocus != NULL)
&& (gInteractableFocus->interactable != NULL)
&& (gInteractableFocus->interactable->on_key_up != NULL);
if (keyFocused) {
gInteractableFocus->interactable->on_key_up(gInteractableFocus, scancode);
sKeyboardHoldDirection = PAD_HOLD_DIR_NONE;