Commit 8735dae3 authored by bfulgham@apple.com's avatar bfulgham@apple.com

[Windows] Unreviewed test fix. Prevent crash when changing URL paths during testing.

A shared BSTR value (_bstr_t) was being reallocated outside the smart pointer, causing
it to be double-freed.

* WinLauncher/WinLauncher.cpp:
(EditProc): Be explicit about type passed to loadURL.
(loadURL): Create a shallow copy of the BSTR so we only allocate memory if needed. Use _bstr_t so
that reallocating the BSTR is done with the knowledge of the smart pointer.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156662 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5294f11b
2013-09-30 Brent Fulgham <bfulgham@apple.com>
[Windows] Unreviewed test fix. Prevent crash when changing URL paths during testing.
A shared BSTR value (_bstr_t) was being reallocated outside the smart pointer, causing
it to be double-freed.
* WinLauncher/WinLauncher.cpp:
(EditProc): Be explicit about type passed to loadURL.
(loadURL): Create a shallow copy of the BSTR so we only allocate memory if needed. Use _bstr_t so
that reallocating the BSTR is done with the knowledge of the smart pointer.
2013-09-30 Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] Fix force_static_libs_as_shared in WebKit2
......
......@@ -882,7 +882,7 @@ LRESULT CALLBACK EditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
strPtr[strLen] = 0;
_bstr_t bstr(strPtr);
loadURL(bstr);
loadURL(bstr.GetBSTR());
return 0;
}
......@@ -931,14 +931,15 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return (INT_PTR)FALSE;
}
static void loadURL(BSTR urlBStr)
static void loadURL(BSTR passedURL)
{
if (urlBStr && urlBStr[0] && (PathFileExists(urlBStr) || PathIsUNC(urlBStr))) {
_bstr_t urlBStr(passedURL);
if (!!urlBStr && (::PathFileExists(urlBStr) || ::PathIsUNC(urlBStr))) {
TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
if (SUCCEEDED(UrlCreateFromPath(urlBStr, fileURL, &fileURLLength, 0)))
SysReAllocString(&urlBStr, fileURL);
if (SUCCEEDED(::UrlCreateFromPath(urlBStr, fileURL, &fileURLLength, 0)))
urlBStr = fileURL;
}
IWebFramePtr frame;
......@@ -951,7 +952,7 @@ static void loadURL(BSTR urlBStr)
if (FAILED(hr))
return;
hr = request->initWithURL(wcsstr(urlBStr, L"://") ? urlBStr : _bstr_t(L"http://") + urlBStr, WebURLRequestUseProtocolCachePolicy, 60);
hr = request->initWithURL(wcsstr(static_cast<wchar_t*>(urlBStr), L"://") ? urlBStr : _bstr_t(L"http://") + urlBStr, WebURLRequestUseProtocolCachePolicy, 60);
if (FAILED(hr))
return;
......
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