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,21 +143,26 @@ static LPWSTR * HTTP_Tokenize(LPCWSTR string, LPCWSTR token_string) ...@@ -143,21 +143,26 @@ static LPWSTR * HTTP_Tokenize(LPCWSTR string, LPCWSTR token_string)
int i; int i;
LPCWSTR next_token; LPCWSTR next_token;
/* empty string has no tokens */ if (string)
if (*string) {
tokens++; /* empty string has no tokens */
/* count tokens */ if (*string)
for (i = 0; string[i]; i++)
if (!strncmpW(string+i, token_string, strlenW(token_string)))
{
DWORD j;
tokens++; tokens++;
/* we want to skip over separators, but not the null terminator */ /* count tokens */
for (j = 0; j < strlenW(token_string) - 1; j++) for (i = 0; string[i]; i++)
if (!string[i+j]) {
break; if (!strncmpW(string+i, token_string, strlenW(token_string)))
i += j; {
DWORD j;
tokens++;
/* we want to skip over separators, but not the null terminator */
for (j = 0; j < strlenW(token_string) - 1; j++)
if (!string[i+j])
break;
i += j;
}
} }
}
/* add 1 for terminating NULL */ /* add 1 for terminating NULL */
token_array = HeapAlloc(GetProcessHeap(), 0, (tokens+1) * sizeof(*token_array)); token_array = HeapAlloc(GetProcessHeap(), 0, (tokens+1) * sizeof(*token_array));
......
...@@ -296,6 +296,12 @@ static void InternetReadFile_test(int flags) ...@@ -296,6 +296,12 @@ static void InternetReadFile_test(int flags)
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError()); ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(buffer, "http://www.winehq.org/about/"), "Wrong URL %s\n", buffer); 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_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME); CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED); 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