From c215c8790dd621cae8d2c0c37015e6b6ca170fbc Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 28 Nov 2025 18:28:24 -0800
Subject: [PATCH] Assert that we've initialized before resolving hostnames
---
src/SDL_net.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/SDL_net.c b/src/SDL_net.c
index 3665522..afefaf4 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -616,6 +616,9 @@ static void trim_whitespace(char *str)
NET_Address *NET_ResolveHostname(const char *host)
{
+ // If this isn't true, we'll spin up resolver threads without locking that will be orphaned in NET_Init()
+ SDL_assert(SDL_GetAtomicInt(&initialize_count) > 0);
+
NET_Address *addr = SDL_calloc(1, sizeof (NET_Address));
if (!addr) {
return NULL;