From 1dc3730782c3a2bcfcf23ef4e4309d55daf75670 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Jun 2026 13:36:18 +0530 Subject: [PATCH] macOS: handle the OS calling insertText: with a nil string Fixes #10152 --- glfw/cocoa_window.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index c72a89dbb..006d01083 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2023,6 +2023,10 @@ - (NSRect)firstRectForCharacterRange:(NSRange)range - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { + if (!string) { + debug_input("\n\tinsertText: nil replacementRange: (%lu, %lu)\n", replacementRange.location, replacementRange.length); + return; + } const char *utf8 = polymorphic_string_as_utf8(string); debug_input("\n\tinsertText: %s replacementRange: (%lu, %lu)\n", utf8, replacementRange.location, replacementRange.length); if ([self hasMarkedText] && !is_ascii_control_char(utf8[0])) {