mirror of
https://github.com/reactos/reactos.git
synced 2025-06-30 03:51:21 +00:00
[ROSTESTS] Fix crash in winhttp:winhttp test (#4303)
Fix regression crash in wine_dbgstr_wn. ROSTESTS-377 This brings most of Wine's current wine_dbgstr_wn code into ReactOS. It's not possible to completely sync this with latest Wine because there is Wine-specific code regarding "debug_info" and their TEB in remaining code. Confirmed by @ThFabba.
This commit is contained in:
parent
57d7f6f6b3
commit
dbc7eeb47e
1 changed files with 17 additions and 20 deletions
|
@ -698,28 +698,22 @@ const char *wine_dbgstr_an( const CHAR *str, intptr_t n )
|
||||||
|
|
||||||
const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
|
const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
|
||||||
{
|
{
|
||||||
char *dst, *res;
|
char *res;
|
||||||
size_t size;
|
static const char hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
|
||||||
|
char buffer[300], *dst = buffer;
|
||||||
|
|
||||||
|
if (!str) return "(null)";
|
||||||
if (!((ULONG_PTR)str >> 16))
|
if (!((ULONG_PTR)str >> 16))
|
||||||
{
|
{
|
||||||
if (!str) return "(null)";
|
|
||||||
res = get_temp_buffer( 6 );
|
res = get_temp_buffer( 6 );
|
||||||
sprintf( res, "#%04x", LOWORD(str) );
|
sprintf( res, "#%04x", LOWORD(str) );
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (n == -1)
|
if (IsBadStringPtrW(str,n)) return "(invalid)";
|
||||||
{
|
if (n == -1) for (n = 0; str[n]; n++) ;
|
||||||
const WCHAR *end = str;
|
|
||||||
while (*end) end++;
|
|
||||||
n = end - str;
|
|
||||||
}
|
|
||||||
if (n < 0) n = 0;
|
|
||||||
size = 12 + min( 300, n * 5 );
|
|
||||||
dst = res = get_temp_buffer( size );
|
|
||||||
*dst++ = 'L';
|
*dst++ = 'L';
|
||||||
*dst++ = '"';
|
*dst++ = '"';
|
||||||
while (n-- > 0 && dst <= res + size - 10)
|
while (n-- > 0 && dst <= buffer + sizeof(buffer) - 10)
|
||||||
{
|
{
|
||||||
WCHAR c = *str++;
|
WCHAR c = *str++;
|
||||||
switch (c)
|
switch (c)
|
||||||
|
@ -730,14 +724,15 @@ const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
|
||||||
case '"': *dst++ = '\\'; *dst++ = '"'; break;
|
case '"': *dst++ = '\\'; *dst++ = '"'; break;
|
||||||
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
|
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
|
||||||
default:
|
default:
|
||||||
if (c >= ' ' && c <= 126)
|
if (c < ' ' || c >= 127)
|
||||||
*dst++ = (char)c;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
*dst++ = '\\';
|
*dst++ = '\\';
|
||||||
sprintf(dst,"%04x",c);
|
*dst++ = hex[(c >> 12) & 0x0f];
|
||||||
dst+=4;
|
*dst++ = hex[(c >> 8) & 0x0f];
|
||||||
|
*dst++ = hex[(c >> 4) & 0x0f];
|
||||||
|
*dst++ = hex[c & 0x0f];
|
||||||
}
|
}
|
||||||
|
else *dst++ = (char)c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*dst++ = '"';
|
*dst++ = '"';
|
||||||
|
@ -747,8 +742,10 @@ const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
|
||||||
*dst++ = '.';
|
*dst++ = '.';
|
||||||
*dst++ = '.';
|
*dst++ = '.';
|
||||||
}
|
}
|
||||||
*dst++ = 0;
|
*dst = 0;
|
||||||
release_temp_buffer( res, dst - res );
|
|
||||||
|
res = get_temp_buffer(strlen(buffer + 1));
|
||||||
|
strcpy(res, buffer);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue