Commit 74b0897c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added TYMED_FILE support to CopyStgMedium.

parent d2243989
......@@ -1183,6 +1183,8 @@ static void test_CopyStgMedium(void)
STGMEDIUM src, dst;
HRESULT hres;
static WCHAR fileW[] = {'f','i','l','e',0};
memset(&src, 0xf0, sizeof(src));
memset(&dst, 0xe0, sizeof(dst));
src.tymed = TYMED_NULL;
......@@ -1203,6 +1205,17 @@ static void test_CopyStgMedium(void)
ok(!dst.u.pstm, "pstm=%p\n", dst.u.pstm);
ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
memset(&dst, 0xe0, sizeof(dst));
src.tymed = TYMED_FILE;
src.u.lpszFileName = fileW;
src.pUnkForRelease = NULL;
hres = CopyStgMedium(&src, &dst);
ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
ok(dst.tymed == TYMED_FILE, "tymed=%d\n", dst.tymed);
ok(dst.u.lpszFileName && dst.u.lpszFileName != fileW, "lpszFileName=%p\n", dst.u.lpszFileName);
ok(!lstrcmpW(dst.u.lpszFileName, fileW), "wrong file name\n");
ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
hres = CopyStgMedium(&src, NULL);
ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
hres = CopyStgMedium(NULL, &dst);
......
......@@ -398,7 +398,6 @@ void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
if(offsetof(BINDINFO, szExtraInfo) < size)
CoTaskMemFree(pbindinfo->szCustomVerb);
if(pbindinfo->pUnk && offsetof(BINDINFO, pUnk) < size)
IUnknown_Release(pbindinfo->pUnk);
......@@ -421,6 +420,13 @@ HRESULT WINAPI CopyStgMedium(const STGMEDIUM *src, STGMEDIUM *dst)
switch(dst->tymed) {
case TYMED_NULL:
break;
case TYMED_FILE:
if(src->u.lpszFileName && !src->pUnkForRelease) {
DWORD size = (strlenW(src->u.lpszFileName)+1)*sizeof(WCHAR);
dst->u.lpszFileName = CoTaskMemAlloc(size);
memcpy(dst->u.lpszFileName, src->u.lpszFileName, size);
}
break;
case TYMED_ISTREAM:
if(dst->u.pstm)
IStream_AddRef(dst->u.pstm);
......
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