Commit 64ff0e54 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

wininet: Initialise the LPWITHREADERROR structure after it has been allocated.

parent 2bcfe8eb
...@@ -3045,6 +3045,26 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, ...@@ -3045,6 +3045,26 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
} }
static LPWITHREADERROR INTERNET_AllocThreadError(void)
{
LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
if (lpwite)
{
lpwite->dwError = 0;
lpwite->response[0] = '\0';
}
if (!TlsSetValue(g_dwTlsErrIndex, lpwite))
{
HeapFree(GetProcessHeap(), 0, lpwite);
return NULL;
}
return lpwite;
}
/*********************************************************************** /***********************************************************************
* INTERNET_SetLastError (internal) * INTERNET_SetLastError (internal)
* *
...@@ -3058,10 +3078,7 @@ void INTERNET_SetLastError(DWORD dwError) ...@@ -3058,10 +3078,7 @@ void INTERNET_SetLastError(DWORD dwError)
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex); LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
if (!lpwite) if (!lpwite)
{ lpwite = INTERNET_AllocThreadError();
lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
TlsSetValue(g_dwTlsErrIndex, lpwite);
}
SetLastError(dwError); SetLastError(dwError);
if(lpwite) if(lpwite)
...@@ -3493,10 +3510,7 @@ LPSTR INTERNET_GetResponseBuffer(void) ...@@ -3493,10 +3510,7 @@ LPSTR INTERNET_GetResponseBuffer(void)
{ {
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex); LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
if (!lpwite) if (!lpwite)
{ lpwite = INTERNET_AllocThreadError();
lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
TlsSetValue(g_dwTlsErrIndex, lpwite);
}
TRACE("\n"); TRACE("\n");
return lpwite->response; return lpwite->response;
} }
......
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