ole32: Clipboard format in the datacache is with trailing \0.
GetClipboardFormatName returns length without terminating 0, but we need to store it with \0. Signed-off-by: Marcus Meissner <marcus@jet.franken.de> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d385de71e3
commit
d382b8e91a
|
@ -470,6 +470,10 @@ static HRESULT read_clipformat(IStream *stream, CLIPFORMAT *clipformat)
|
||||||
hr = IStream_Read(stream, &length, sizeof(length), &read);
|
hr = IStream_Read(stream, &length, sizeof(length), &read);
|
||||||
if (hr != S_OK || read != sizeof(length))
|
if (hr != S_OK || read != sizeof(length))
|
||||||
return DV_E_CLIPFORMAT;
|
return DV_E_CLIPFORMAT;
|
||||||
|
if (!length) {
|
||||||
|
/* No clipboard format present */
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
if (length == -1)
|
if (length == -1)
|
||||||
{
|
{
|
||||||
DWORD cf;
|
DWORD cf;
|
||||||
|
@ -499,11 +503,16 @@ static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
|
||||||
{
|
{
|
||||||
DWORD length;
|
DWORD length;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
char format_name[256];
|
||||||
|
|
||||||
if (clipformat < 0xc000)
|
if (clipformat < 0xc000)
|
||||||
length = -1;
|
length = -1;
|
||||||
else
|
else
|
||||||
length = GetClipboardFormatNameA(clipformat, NULL, 0);
|
{
|
||||||
|
length = GetClipboardFormatNameA(clipformat, format_name, sizeof(format_name));
|
||||||
|
/* If there is a clipboard format name, we need to include its terminating \0 */
|
||||||
|
if (length) length++;
|
||||||
|
}
|
||||||
hr = IStream_Write(stream, &length, sizeof(length), NULL);
|
hr = IStream_Write(stream, &length, sizeof(length), NULL);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -514,12 +523,7 @@ static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *format_name = HeapAlloc(GetProcessHeap(), 0, length);
|
|
||||||
if (!format_name)
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
GetClipboardFormatNameA(clipformat, format_name, length);
|
|
||||||
hr = IStream_Write(stream, format_name, length, NULL);
|
hr = IStream_Write(stream, format_name, length, NULL);
|
||||||
HeapFree(GetProcessHeap(), 0, format_name);
|
|
||||||
}
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue