Commit 086a91fa authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

urlmon: Check some of the input parameters to URLOpenStreamA/W & URLOpenBlockingStreamA/W for NULL.

Add tests for these.
parent a5da813f
...@@ -297,6 +297,11 @@ static void test_URLOpenBlockingStreamW(void) ...@@ -297,6 +297,11 @@ static void test_URLOpenBlockingStreamW(void)
IStream *pStream; IStream *pStream;
char buffer[256]; char buffer[256];
hr = URLOpenBlockingStreamW(NULL, NULL, &pStream, 0, &BindStatusCallback);
ok(hr == E_INVALIDARG, "URLOpenBlockingStreamW should have failed with E_INVALIDARG instead of 0x%08x\n", hr);
hr = URLOpenBlockingStreamW(NULL, INDEX_HTML, NULL, 0, &BindStatusCallback);
ok(hr == E_INVALIDARG, "URLOpenBlockingStreamW should have failed with E_INVALIDARG instead of 0x%08x\n", hr);
SET_EXPECT(GetBindInfo); SET_EXPECT(GetBindInfo);
SET_EXPECT(QueryInterface_IServiceProvider); SET_EXPECT(QueryInterface_IServiceProvider);
SET_EXPECT(OnStartBinding); SET_EXPECT(OnStartBinding);
...@@ -331,6 +336,9 @@ static void test_URLOpenStreamW(void) ...@@ -331,6 +336,9 @@ static void test_URLOpenStreamW(void)
{ {
HRESULT hr; HRESULT hr;
hr = URLOpenStreamW(NULL, NULL, 0, &BindStatusCallback);
ok(hr == E_INVALIDARG, "URLOpenStreamW should have failed with E_INVALIDARG instead of 0x%08x\n", hr);
SET_EXPECT(GetBindInfo); SET_EXPECT(GetBindInfo);
SET_EXPECT(QueryInterface_IServiceProvider); SET_EXPECT(QueryInterface_IServiceProvider);
SET_EXPECT(OnStartBinding); SET_EXPECT(OnStartBinding);
......
...@@ -559,10 +559,16 @@ HRESULT WINAPI URLOpenBlockingStreamA(LPUNKNOWN pCaller, LPCSTR szURL, ...@@ -559,10 +559,16 @@ HRESULT WINAPI URLOpenBlockingStreamA(LPUNKNOWN pCaller, LPCSTR szURL,
TRACE("(%p, %s, %p, 0x%x, %p)\n", pCaller, szURL, ppStream, dwReserved, lpfnCB); TRACE("(%p, %s, %p, 0x%x, %p)\n", pCaller, szURL, ppStream, dwReserved, lpfnCB);
if (!szURL || !ppStream)
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!szURLW) if (!szURLW)
{
*ppStream = NULL;
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
MultiByteToWideChar(CP_ACP, 0, szURL, -1, szURLW, len); MultiByteToWideChar(CP_ACP, 0, szURL, -1, szURLW, len);
hr = URLOpenBlockingStreamW(pCaller, szURLW, ppStream, dwReserved, lpfnCB); hr = URLOpenBlockingStreamW(pCaller, szURLW, ppStream, dwReserved, lpfnCB);
...@@ -584,6 +590,9 @@ HRESULT WINAPI URLOpenBlockingStreamW(LPUNKNOWN pCaller, LPCWSTR szURL, ...@@ -584,6 +590,9 @@ HRESULT WINAPI URLOpenBlockingStreamW(LPUNKNOWN pCaller, LPCWSTR szURL,
TRACE("(%p, %s, %p, 0x%x, %p)\n", pCaller, debugstr_w(szURL), ppStream, TRACE("(%p, %s, %p, 0x%x, %p)\n", pCaller, debugstr_w(szURL), ppStream,
dwReserved, lpfnCB); dwReserved, lpfnCB);
if (!szURL || !ppStream)
return E_INVALIDARG;
blocking_bsc.lpVtbl = &BlockingBindStatusCallbackVtbl; blocking_bsc.lpVtbl = &BlockingBindStatusCallbackVtbl;
blocking_bsc.pBSC = lpfnCB; blocking_bsc.pBSC = lpfnCB;
...@@ -602,6 +611,9 @@ HRESULT WINAPI URLOpenStreamA(LPUNKNOWN pCaller, LPCSTR szURL, DWORD dwReserved, ...@@ -602,6 +611,9 @@ HRESULT WINAPI URLOpenStreamA(LPUNKNOWN pCaller, LPCSTR szURL, DWORD dwReserved,
TRACE("(%p, %s, 0x%x, %p)\n", pCaller, szURL, dwReserved, lpfnCB); TRACE("(%p, %s, 0x%x, %p)\n", pCaller, szURL, dwReserved, lpfnCB);
if (!szURL)
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!szURLW) if (!szURLW)
...@@ -628,6 +640,9 @@ HRESULT WINAPI URLOpenStreamW(LPUNKNOWN pCaller, LPCWSTR szURL, DWORD dwReserved ...@@ -628,6 +640,9 @@ HRESULT WINAPI URLOpenStreamW(LPUNKNOWN pCaller, LPCWSTR szURL, DWORD dwReserved
TRACE("(%p, %s, 0x%x, %p)\n", pCaller, debugstr_w(szURL), dwReserved, TRACE("(%p, %s, 0x%x, %p)\n", pCaller, debugstr_w(szURL), dwReserved,
lpfnCB); lpfnCB);
if (!szURL)
return E_INVALIDARG;
async_bsc.lpVtbl = &AsyncBindStatusCallbackVtbl; async_bsc.lpVtbl = &AsyncBindStatusCallbackVtbl;
async_bsc.pBSC = lpfnCB; async_bsc.pBSC = lpfnCB;
......
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