InputText: amend fix to avoid PVS-Studio sort of rightful false positive. Amend f4c2f50. (#9174)

Checking for state != NULL in the two othr functions where state is already deferenced was misleading.
imgui_widgets.cpp:4496:1: error: V595 The 'state' pointer was utilized before it was verified against nullptr. Check lines: 4496, 4500.
imgui_widgets.cpp:5273:1: error: V595 The 'state' pointer was utilized before it was verified against nullptr. Check lines: 5273, 5289.
This commit is contained in:
ocornut
2026-03-18 18:57:02 +01:00
parent f4c2f50896
commit 6abe65aac6

View File

@@ -4402,6 +4402,7 @@ void ImGui::PopPasswordFont()
// Return false to discard a character.
static bool InputTextFilterCharacter(ImGuiContext* ctx, ImGuiInputTextState* state, unsigned int* p_char, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard)
{
IM_ASSERT(state != NULL);
unsigned int c = *p_char;
ImGuiInputTextFlags flags = state->Flags;
@@ -4497,7 +4498,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, ImGuiInputTextState* sta
callback_data.Flags = flags;
callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
callback_data.EventChar = (ImWchar)c;
callback_data.EventActivated = (state && g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.UserData = user_data;
if (callback(&callback_data) != 0)
return false;
@@ -5286,7 +5287,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
callback_data.ID = id;
callback_data.Flags = flags;
callback_data.EventFlag = event_flag;
callback_data.EventActivated = (state && g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.UserData = callback_user_data;
// FIXME-OPT: Undo stack reconcile needs a backup of the data until we rework API, see #7925