Commit 0715d9c1 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

wininet: Fix crash when calling HttpQueryInfoA/W(HTTP_QUERY_RAW_HEADERS) before…

wininet: Fix crash when calling HttpQueryInfoA/W(HTTP_QUERY_RAW_HEADERS) before any response has been received from a server.
parent dbd1800a
......@@ -143,11 +143,14 @@ static LPWSTR * HTTP_Tokenize(LPCWSTR string, LPCWSTR token_string)
int i;
LPCWSTR next_token;
if (string)
{
/* empty string has no tokens */
if (*string)
tokens++;
/* count tokens */
for (i = 0; string[i]; i++)
{
if (!strncmpW(string+i, token_string, strlenW(token_string)))
{
DWORD j;
......@@ -158,6 +161,8 @@ static LPWSTR * HTTP_Tokenize(LPCWSTR string, LPCWSTR token_string)
break;
i += j;
}
}
}
/* add 1 for terminating NULL */
token_array = HeapAlloc(GetProcessHeap(), 0, (tokens+1) * sizeof(*token_array));
......
......@@ -296,6 +296,12 @@ static void InternetReadFile_test(int flags)
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(buffer, "http://www.winehq.org/about/"), "Wrong URL %s\n", buffer);
length = sizeof(buffer);
res = HttpQueryInfoA(hor, HTTP_QUERY_RAW_HEADERS, buffer, &length, 0x0);
ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
ok(length == 0, "HTTP_QUERY_RAW_HEADERS: expected length 0, but got %d\n", length);
ok(!strcmp(buffer, ""), "HTTP_QUERY_RAW_HEADERS: expected string \"\", but got \"%s\"\n", buffer);
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED);
......
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