Commit c66c14dd authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

ws2_32: Move the buffer used by inet_ntoa into the per-thread data.

parent 3a56f9b9
...@@ -378,6 +378,7 @@ struct per_thread_data ...@@ -378,6 +378,7 @@ struct per_thread_data
int he_len; int he_len;
int se_len; int se_len;
int pe_len; int pe_len;
char ntoa_buffer[16]; /* 4*3 digits + 3 '.' + 1 '\0' */
}; };
/* internal: routing description information */ /* internal: routing description information */
...@@ -3525,17 +3526,12 @@ WS_u_short WINAPI WS_ntohs(WS_u_short netshort) ...@@ -3525,17 +3526,12 @@ WS_u_short WINAPI WS_ntohs(WS_u_short netshort)
*/ */
char* WINAPI WS_inet_ntoa(struct WS_in_addr in) char* WINAPI WS_inet_ntoa(struct WS_in_addr in)
{ {
/* use "buffer for dummies" here because some applications have a
* propensity to decode addresses in ws_hostent structure without
* saving them first...
*/
static char dbuffer[16]; /* Yes, 16: 4*3 digits + 3 '.' + 1 '\0' */
char* s = inet_ntoa(*((struct in_addr*)&in)); char* s = inet_ntoa(*((struct in_addr*)&in));
if( s ) if( s )
{ {
strcpy(dbuffer, s); struct per_thread_data *data = get_per_thread_data();
return dbuffer; strcpy(data->ntoa_buffer, s);
return data->ntoa_buffer;
} }
SetLastError(wsaErrno()); SetLastError(wsaErrno());
return NULL; return NULL;
......
...@@ -7073,7 +7073,6 @@ static void test_inet_ntoa(void) ...@@ -7073,7 +7073,6 @@ static void test_inet_ntoa(void)
thread = CreateThread(NULL, 0, inet_ntoa_thread_proc, event, 0, &tid); thread = CreateThread(NULL, 0, inet_ntoa_thread_proc, event, 0, &tid);
WaitForSingleObject(event[0], 3000); WaitForSingleObject(event[0], 3000);
todo_wine
ok(!strcmp(str, "1.2.3.4"), "expected 1.2.3.4, got %s\n", str); ok(!strcmp(str, "1.2.3.4"), "expected 1.2.3.4, got %s\n", str);
SetEvent(event[1]); SetEvent(event[1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment