File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,27 @@ void NET_Quit(void)
492492 #endif
493493}
494494
495+ static void trim_whitespace (char * str )
496+ {
497+ char * ptr ;
498+ for (ptr = str ; * ptr ; ptr ++ ) {
499+ if (!SDL_isspace (* ptr )) {
500+ break ;
501+ }
502+ }
503+
504+ if (ptr > str ) {
505+ SDL_memmove (str , ptr , SDL_strlen (ptr ) + 1 );
506+ }
507+
508+ for (ptr = str + (SDL_strlen (str ) - 1 ); ptr >= str ; ptr -- ) {
509+ if (!SDL_isspace (* ptr )) {
510+ break ;
511+ }
512+ * ptr = '\0' ;
513+ }
514+ }
515+
495516NET_Address * NET_ResolveHostname (const char * host )
496517{
497518 NET_Address * addr = SDL_calloc (1 , sizeof (NET_Address ));
@@ -505,6 +526,9 @@ NET_Address *NET_ResolveHostname(const char *host)
505526 return NULL ;
506527 }
507528
529+ // remove whitespace around name, just in case. https://github.com/libsdl-org/SDL_net/issues/148
530+ trim_whitespace (addr -> hostname );
531+
508532 SDL_SetAtomicInt (& addr -> refcount , 2 ); // one for creation, one for the resolver thread to unref when done.
509533
510534 SDL_LockMutex (resolver_lock );
You can’t perform that action at this time.
0 commit comments