Module: wine Branch: refs/heads/master Commit: 64ff0e54a3385e3200bfc71aa29f41a3425faaa0 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=64ff0e54a3385e3200bfc71a...
Author: Robert Shearman rob@codeweavers.com Date: Wed Apr 26 15:44:14 2006 +0100
wininet: Initialise the LPWITHREADERROR structure after it has been allocated.
---
dlls/wininet/internet.c | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index d504981..8c2f08e 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -3045,6 +3045,26 @@ HINTERNET WINAPI InternetOpenUrlA(HINTER }
+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) * @@ -3058,10 +3078,7 @@ void INTERNET_SetLastError(DWORD dwError LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
if (!lpwite) - { - lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite)); - TlsSetValue(g_dwTlsErrIndex, lpwite); - } + lpwite = INTERNET_AllocThreadError();
SetLastError(dwError); if(lpwite) @@ -3493,10 +3510,7 @@ LPSTR INTERNET_GetResponseBuffer(void) { LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex); if (!lpwite) - { - lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite)); - TlsSetValue(g_dwTlsErrIndex, lpwite); - } + lpwite = INTERNET_AllocThreadError(); TRACE("\n"); return lpwite->response; }