diff --git a/HellionChat/Ui/ChatLogWindow.cs b/HellionChat/Ui/ChatLogWindow.cs index 9318935..072cb5f 100644 --- a/HellionChat/Ui/ChatLogWindow.cs +++ b/HellionChat/Ui/ChatLogWindow.cs @@ -1130,18 +1130,29 @@ public sealed class ChatLogWindow : Window // so the inserted token cannot expand to nothing. unsafe { - var flagSet = AgentMap.Instance()->FlagMarkerCount > 0; + // Null-check before deref: pointers can be null during zone transitions. + var agentMap = AgentMap.Instance(); + var flagSet = agentMap != null && agentMap->FlagMarkerCount > 0; using (ImRaii.Disabled(!flagSet)) { if (ImGui.Selectable(HellionStrings.ChatLog_Insert_MapFlag)) + { Chat += ""; + Activate = true; + ActivatePos = Chat.Length; + } } - var itemSet = AgentChatLog.Instance()->LinkedItem.ItemId != 0; + var agentChat = AgentChatLog.Instance(); + var itemSet = agentChat != null && agentChat->LinkedItem.ItemId != 0; using (ImRaii.Disabled(!itemSet)) { if (ImGui.Selectable(HellionStrings.ChatLog_Insert_ItemLink)) + { Chat += ""; + Activate = true; + ActivatePos = Chat.Length; + } } } }