src/string.c

changeset 1693
c2d05cf1a062
parent 1685
0344372c7115
--- a/src/string.c	Wed Dec 31 15:11:12 2025 +0100
+++ b/src/string.c	Wed Dec 31 15:25:30 2025 +0100
@@ -41,7 +41,12 @@
 #include <ctype.h>
 
 #ifdef _WIN32
-#define cx_strcasecmp_impl _strnicmp
+static int cx_fixed_strnicmp(const char* s1, const char* s2, size_t count) {
+    // Microsoft's implementation crashes when count == 0 and either string is NULL
+    if (count == 0) return 0;
+    return _strnicmp(s1, s2, count);
+}
+#define cx_strcasecmp_impl cx_fixed_strnicmp
 #else
 #include <strings.h>
 #define cx_strcasecmp_impl strncasecmp

mercurial