windowscodecs: PROPVARIANT fields should use CoTaskMem allocation.
This commit is contained in:
parent
c77642ec52
commit
36e5836e5d
3 changed files with 72 additions and 81 deletions
dlls/windowscodecs
|
@ -25,6 +25,7 @@
|
|||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "objbase.h"
|
||||
#include "shlwapi.h"
|
||||
|
||||
#include "ungif.h"
|
||||
|
||||
|
@ -68,14 +69,6 @@ struct image_descriptor
|
|||
|
||||
#include "poppack.h"
|
||||
|
||||
static LPWSTR strdupAtoW(const char *src)
|
||||
{
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
|
||||
LPWSTR dst = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||
if (dst) MultiByteToWideChar(CP_ACP, 0, src, -1, dst, len);
|
||||
return dst;
|
||||
}
|
||||
|
||||
static HRESULT load_LSD_metadata(IStream *stream, const GUID *vendor, DWORD options,
|
||||
MetadataItem **items, DWORD *count)
|
||||
{
|
||||
|
@ -101,49 +94,49 @@ static HRESULT load_LSD_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
}
|
||||
|
||||
result[0].id.vt = VT_LPWSTR;
|
||||
result[0].id.pwszVal = strdupAtoW("Signature");
|
||||
SHStrDupW(L"Signature", &result[0].id.pwszVal);
|
||||
result[0].value.vt = VT_UI1|VT_VECTOR;
|
||||
result[0].value.caub.cElems = sizeof(lsd_data.signature);
|
||||
result[0].value.caub.pElems = HeapAlloc(GetProcessHeap(), 0, sizeof(lsd_data.signature));
|
||||
result[0].value.caub.pElems = CoTaskMemAlloc(sizeof(lsd_data.signature));
|
||||
memcpy(result[0].value.caub.pElems, lsd_data.signature, sizeof(lsd_data.signature));
|
||||
|
||||
result[1].id.vt = VT_LPWSTR;
|
||||
result[1].id.pwszVal = strdupAtoW("Width");
|
||||
SHStrDupW(L"Width", &result[1].id.pwszVal);
|
||||
result[1].value.vt = VT_UI2;
|
||||
result[1].value.uiVal = lsd_data.width;
|
||||
|
||||
result[2].id.vt = VT_LPWSTR;
|
||||
result[2].id.pwszVal = strdupAtoW("Height");
|
||||
SHStrDupW(L"Height", &result[2].id.pwszVal);
|
||||
result[2].value.vt = VT_UI2;
|
||||
result[2].value.uiVal = lsd_data.height;
|
||||
|
||||
result[3].id.vt = VT_LPWSTR;
|
||||
result[3].id.pwszVal = strdupAtoW("GlobalColorTableFlag");
|
||||
SHStrDupW(L"GlobalColorTableFlag", &result[3].id.pwszVal);
|
||||
result[3].value.vt = VT_BOOL;
|
||||
result[3].value.boolVal = (lsd_data.packed >> 7) & 1;
|
||||
|
||||
result[4].id.vt = VT_LPWSTR;
|
||||
result[4].id.pwszVal = strdupAtoW("ColorResolution");
|
||||
SHStrDupW(L"ColorResolution", &result[4].id.pwszVal);
|
||||
result[4].value.vt = VT_UI1;
|
||||
result[4].value.bVal = (lsd_data.packed >> 4) & 7;
|
||||
|
||||
result[5].id.vt = VT_LPWSTR;
|
||||
result[5].id.pwszVal = strdupAtoW("SortFlag");
|
||||
SHStrDupW(L"SortFlag", &result[5].id.pwszVal);
|
||||
result[5].value.vt = VT_BOOL;
|
||||
result[5].value.boolVal = (lsd_data.packed >> 3) & 1;
|
||||
|
||||
result[6].id.vt = VT_LPWSTR;
|
||||
result[6].id.pwszVal = strdupAtoW("GlobalColorTableSize");
|
||||
SHStrDupW(L"GlobalColorTableSize", &result[6].id.pwszVal);
|
||||
result[6].value.vt = VT_UI1;
|
||||
result[6].value.bVal = lsd_data.packed & 7;
|
||||
|
||||
result[7].id.vt = VT_LPWSTR;
|
||||
result[7].id.pwszVal = strdupAtoW("BackgroundColorIndex");
|
||||
SHStrDupW(L"BackgroundColorIndex", &result[7].id.pwszVal);
|
||||
result[7].value.vt = VT_UI1;
|
||||
result[7].value.bVal = lsd_data.background_color_index;
|
||||
|
||||
result[8].id.vt = VT_LPWSTR;
|
||||
result[8].id.pwszVal = strdupAtoW("PixelAspectRatio");
|
||||
SHStrDupW(L"PixelAspectRatio", &result[8].id.pwszVal);
|
||||
result[8].value.vt = VT_UI1;
|
||||
result[8].value.bVal = lsd_data.pixel_aspect_ratio;
|
||||
|
||||
|
@ -189,42 +182,42 @@ static HRESULT load_IMD_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
}
|
||||
|
||||
result[0].id.vt = VT_LPWSTR;
|
||||
result[0].id.pwszVal = strdupAtoW("Left");
|
||||
SHStrDupW(L"Left", &result[0].id.pwszVal);
|
||||
result[0].value.vt = VT_UI2;
|
||||
result[0].value.uiVal = imd_data.left;
|
||||
|
||||
result[1].id.vt = VT_LPWSTR;
|
||||
result[1].id.pwszVal = strdupAtoW("Top");
|
||||
SHStrDupW(L"Top", &result[1].id.pwszVal);
|
||||
result[1].value.vt = VT_UI2;
|
||||
result[1].value.uiVal = imd_data.top;
|
||||
|
||||
result[2].id.vt = VT_LPWSTR;
|
||||
result[2].id.pwszVal = strdupAtoW("Width");
|
||||
SHStrDupW(L"Width", &result[2].id.pwszVal);
|
||||
result[2].value.vt = VT_UI2;
|
||||
result[2].value.uiVal = imd_data.width;
|
||||
|
||||
result[3].id.vt = VT_LPWSTR;
|
||||
result[3].id.pwszVal = strdupAtoW("Height");
|
||||
SHStrDupW(L"Height", &result[3].id.pwszVal);
|
||||
result[3].value.vt = VT_UI2;
|
||||
result[3].value.uiVal = imd_data.height;
|
||||
|
||||
result[4].id.vt = VT_LPWSTR;
|
||||
result[4].id.pwszVal = strdupAtoW("LocalColorTableFlag");
|
||||
SHStrDupW(L"LocalColorTableFlag", &result[4].id.pwszVal);
|
||||
result[4].value.vt = VT_BOOL;
|
||||
result[4].value.boolVal = (imd_data.packed >> 7) & 1;
|
||||
|
||||
result[5].id.vt = VT_LPWSTR;
|
||||
result[5].id.pwszVal = strdupAtoW("InterlaceFlag");
|
||||
SHStrDupW(L"InterlaceFlag", &result[5].id.pwszVal);
|
||||
result[5].value.vt = VT_BOOL;
|
||||
result[5].value.boolVal = (imd_data.packed >> 6) & 1;
|
||||
|
||||
result[6].id.vt = VT_LPWSTR;
|
||||
result[6].id.pwszVal = strdupAtoW("SortFlag");
|
||||
SHStrDupW(L"SortFlag", &result[6].id.pwszVal);
|
||||
result[6].value.vt = VT_BOOL;
|
||||
result[6].value.boolVal = (imd_data.packed >> 5) & 1;
|
||||
|
||||
result[7].id.vt = VT_LPWSTR;
|
||||
result[7].id.pwszVal = strdupAtoW("LocalColorTableSize");
|
||||
SHStrDupW(L"LocalColorTableSize", &result[7].id.pwszVal);
|
||||
result[7].value.vt = VT_UI1;
|
||||
result[7].value.bVal = imd_data.packed & 7;
|
||||
|
||||
|
@ -282,27 +275,27 @@ static HRESULT load_GCE_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
}
|
||||
|
||||
result[0].id.vt = VT_LPWSTR;
|
||||
result[0].id.pwszVal = strdupAtoW("Disposal");
|
||||
SHStrDupW(L"Disposal", &result[0].id.pwszVal);
|
||||
result[0].value.vt = VT_UI1;
|
||||
result[0].value.bVal = (gce_data.packed >> 2) & 7;
|
||||
|
||||
result[1].id.vt = VT_LPWSTR;
|
||||
result[1].id.pwszVal = strdupAtoW("UserInputFlag");
|
||||
SHStrDupW(L"UserInputFlag", &result[1].id.pwszVal);
|
||||
result[1].value.vt = VT_BOOL;
|
||||
result[1].value.boolVal = (gce_data.packed >> 1) & 1;
|
||||
|
||||
result[2].id.vt = VT_LPWSTR;
|
||||
result[2].id.pwszVal = strdupAtoW("TransparencyFlag");
|
||||
SHStrDupW(L"TransparencyFlag", &result[2].id.pwszVal);
|
||||
result[2].value.vt = VT_BOOL;
|
||||
result[2].value.boolVal = gce_data.packed & 1;
|
||||
|
||||
result[3].id.vt = VT_LPWSTR;
|
||||
result[3].id.pwszVal = strdupAtoW("Delay");
|
||||
SHStrDupW(L"Delay", &result[3].id.pwszVal);
|
||||
result[3].value.vt = VT_UI2;
|
||||
result[3].value.uiVal = gce_data.delay;
|
||||
|
||||
result[4].id.vt = VT_LPWSTR;
|
||||
result[4].id.pwszVal = strdupAtoW("TransparentColorIndex");
|
||||
SHStrDupW(L"TransparentColorIndex", &result[4].id.pwszVal);
|
||||
result[4].value.vt = VT_UI1;
|
||||
result[4].value.bVal = gce_data.transparent_color_index;
|
||||
|
||||
|
@ -359,19 +352,19 @@ static HRESULT load_APE_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
hr = IStream_Read(stream, &subblock_size, sizeof(subblock_size), &bytesread);
|
||||
if (FAILED(hr) || bytesread != sizeof(subblock_size))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return S_OK;
|
||||
}
|
||||
if (!subblock_size) break;
|
||||
|
||||
if (!data)
|
||||
data = HeapAlloc(GetProcessHeap(), 0, subblock_size + 1);
|
||||
data = CoTaskMemAlloc(subblock_size + 1);
|
||||
else
|
||||
{
|
||||
BYTE *new_data = HeapReAlloc(GetProcessHeap(), 0, data, data_size + subblock_size + 1);
|
||||
BYTE *new_data = CoTaskMemRealloc(data, data_size + subblock_size + 1);
|
||||
if (!new_data)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return S_OK;
|
||||
}
|
||||
data = new_data;
|
||||
|
@ -380,7 +373,7 @@ static HRESULT load_APE_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
hr = IStream_Read(stream, data + data_size + 1, subblock_size, &bytesread);
|
||||
if (FAILED(hr) || bytesread != subblock_size)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return S_OK;
|
||||
}
|
||||
data_size += subblock_size + 1;
|
||||
|
@ -389,7 +382,7 @@ static HRESULT load_APE_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
result = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MetadataItem) * 2);
|
||||
if (!result)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -401,14 +394,14 @@ static HRESULT load_APE_metadata(IStream *stream, const GUID *vendor, DWORD opti
|
|||
}
|
||||
|
||||
result[0].id.vt = VT_LPWSTR;
|
||||
result[0].id.pwszVal = strdupAtoW("Application");
|
||||
SHStrDupW(L"Application", &result[0].id.pwszVal);
|
||||
result[0].value.vt = VT_UI1|VT_VECTOR;
|
||||
result[0].value.caub.cElems = sizeof(ape_data.application);
|
||||
result[0].value.caub.pElems = HeapAlloc(GetProcessHeap(), 0, sizeof(ape_data.application));
|
||||
result[0].value.caub.pElems = CoTaskMemAlloc(sizeof(ape_data.application));
|
||||
memcpy(result[0].value.caub.pElems, ape_data.application, sizeof(ape_data.application));
|
||||
|
||||
result[1].id.vt = VT_LPWSTR;
|
||||
result[1].id.pwszVal = strdupAtoW("Data");
|
||||
SHStrDupW(L"Data", &result[1].id.pwszVal);
|
||||
result[1].value.vt = VT_UI1|VT_VECTOR;
|
||||
result[1].value.caub.cElems = data_size;
|
||||
result[1].value.caub.pElems = data;
|
||||
|
@ -463,19 +456,19 @@ static HRESULT load_GifComment_metadata(IStream *stream, const GUID *vendor, DWO
|
|||
hr = IStream_Read(stream, &subblock_size, sizeof(subblock_size), &bytesread);
|
||||
if (FAILED(hr) || bytesread != sizeof(subblock_size))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return S_OK;
|
||||
}
|
||||
if (!subblock_size) break;
|
||||
|
||||
if (!data)
|
||||
data = HeapAlloc(GetProcessHeap(), 0, subblock_size + 1);
|
||||
data = CoTaskMemAlloc(subblock_size + 1);
|
||||
else
|
||||
{
|
||||
char *new_data = HeapReAlloc(GetProcessHeap(), 0, data, data_size + subblock_size + 1);
|
||||
char *new_data = CoTaskMemRealloc(data, data_size + subblock_size + 1);
|
||||
if (!new_data)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return S_OK;
|
||||
}
|
||||
data = new_data;
|
||||
|
@ -483,7 +476,7 @@ static HRESULT load_GifComment_metadata(IStream *stream, const GUID *vendor, DWO
|
|||
hr = IStream_Read(stream, data + data_size, subblock_size, &bytesread);
|
||||
if (FAILED(hr) || bytesread != subblock_size)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return S_OK;
|
||||
}
|
||||
data_size += subblock_size;
|
||||
|
@ -494,7 +487,7 @@ static HRESULT load_GifComment_metadata(IStream *stream, const GUID *vendor, DWO
|
|||
result = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MetadataItem));
|
||||
if (!result)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -503,7 +496,7 @@ static HRESULT load_GifComment_metadata(IStream *stream, const GUID *vendor, DWO
|
|||
PropVariantInit(&result->value);
|
||||
|
||||
result->id.vt = VT_LPWSTR;
|
||||
result->id.pwszVal = strdupAtoW("TextEntry");
|
||||
SHStrDupW(L"TextEntry", &result->id.pwszVal);
|
||||
result->value.vt = VT_LPSTR;
|
||||
result->value.pszVal = data;
|
||||
|
||||
|
|
|
@ -626,21 +626,21 @@ static HRESULT LoadUnknownMetadata(IStream *input, const GUID *preferred_vendor,
|
|||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
data = HeapAlloc(GetProcessHeap(), 0, stat.cbSize.QuadPart);
|
||||
data = CoTaskMemAlloc(stat.cbSize.QuadPart);
|
||||
if (!data) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IStream_Read(input, data, stat.cbSize.QuadPart, &bytesread);
|
||||
if (bytesread != stat.cbSize.QuadPart) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return hr;
|
||||
}
|
||||
|
||||
result = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MetadataItem));
|
||||
if (!result)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
CoTaskMemFree(data);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -754,7 +754,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
{
|
||||
item->value.vt |= VT_VECTOR;
|
||||
item->value.caub.cElems = count;
|
||||
item->value.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count);
|
||||
item->value.caub.pElems = CoTaskMemAlloc(count);
|
||||
memcpy(item->value.caub.pElems, data, count);
|
||||
}
|
||||
break;
|
||||
|
@ -762,21 +762,21 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
|
||||
item->value.vt |= VT_VECTOR;
|
||||
item->value.caub.cElems = count;
|
||||
item->value.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count);
|
||||
item->value.caub.pElems = CoTaskMemAlloc(count);
|
||||
if (!item->value.caub.pElems) return E_OUTOFMEMORY;
|
||||
|
||||
pos.QuadPart = value;
|
||||
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.caub.pElems);
|
||||
CoTaskMemFree(item->value.caub.pElems);
|
||||
return hr;
|
||||
}
|
||||
hr = IStream_Read(input, item->value.caub.pElems, count, &bytesread);
|
||||
if (bytesread != count) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.caub.pElems);
|
||||
CoTaskMemFree(item->value.caub.pElems);
|
||||
return hr;
|
||||
}
|
||||
break;
|
||||
|
@ -797,7 +797,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
{
|
||||
item->value.vt |= VT_VECTOR;
|
||||
item->value.caui.cElems = count;
|
||||
item->value.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2);
|
||||
item->value.caui.pElems = CoTaskMemAlloc(count * 2);
|
||||
memcpy(item->value.caui.pElems, data, count * 2);
|
||||
for (i = 0; i < count; i++)
|
||||
SWAP_USHORT(item->value.caui.pElems[i]);
|
||||
|
@ -807,21 +807,21 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
|
||||
item->value.vt |= VT_VECTOR;
|
||||
item->value.caui.cElems = count;
|
||||
item->value.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2);
|
||||
item->value.caui.pElems = CoTaskMemAlloc(count * 2);
|
||||
if (!item->value.caui.pElems) return E_OUTOFMEMORY;
|
||||
|
||||
pos.QuadPart = value;
|
||||
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.caui.pElems);
|
||||
CoTaskMemFree(item->value.caui.pElems);
|
||||
return hr;
|
||||
}
|
||||
hr = IStream_Read(input, item->value.caui.pElems, count * 2, &bytesread);
|
||||
if (bytesread != count * 2) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.caui.pElems);
|
||||
CoTaskMemFree(item->value.caui.pElems);
|
||||
return hr;
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
|
@ -840,21 +840,21 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
|
||||
item->value.vt |= VT_VECTOR;
|
||||
item->value.caul.cElems = count;
|
||||
item->value.caul.pElems = HeapAlloc(GetProcessHeap(), 0, count * 4);
|
||||
item->value.caul.pElems = CoTaskMemAlloc(count * 4);
|
||||
if (!item->value.caul.pElems) return E_OUTOFMEMORY;
|
||||
|
||||
pos.QuadPart = value;
|
||||
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.caul.pElems);
|
||||
CoTaskMemFree(item->value.caul.pElems);
|
||||
return hr;
|
||||
}
|
||||
hr = IStream_Read(input, item->value.caul.pElems, count * 4, &bytesread);
|
||||
if (bytesread != count * 4) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.caul.pElems);
|
||||
CoTaskMemFree(item->value.caul.pElems);
|
||||
return hr;
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
|
@ -897,21 +897,21 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
{
|
||||
item->value.vt |= VT_VECTOR;
|
||||
item->value.cauh.cElems = count;
|
||||
item->value.cauh.pElems = HeapAlloc(GetProcessHeap(), 0, count * 8);
|
||||
item->value.cauh.pElems = CoTaskMemAlloc(count * 8);
|
||||
if (!item->value.cauh.pElems) return E_OUTOFMEMORY;
|
||||
|
||||
pos.QuadPart = value;
|
||||
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.cauh.pElems);
|
||||
CoTaskMemFree(item->value.cauh.pElems);
|
||||
return hr;
|
||||
}
|
||||
hr = IStream_Read(input, item->value.cauh.pElems, count * 8, &bytesread);
|
||||
if (bytesread != count * 8) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.cauh.pElems);
|
||||
CoTaskMemFree(item->value.cauh.pElems);
|
||||
return hr;
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
|
@ -927,7 +927,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
}
|
||||
break;
|
||||
case IFD_ASCII:
|
||||
item->value.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1);
|
||||
item->value.pszVal = CoTaskMemAlloc(count + 1);
|
||||
if (!item->value.pszVal) return E_OUTOFMEMORY;
|
||||
|
||||
if (count <= 4)
|
||||
|
@ -942,14 +942,14 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.pszVal);
|
||||
CoTaskMemFree(item->value.pszVal);
|
||||
return hr;
|
||||
}
|
||||
hr = IStream_Read(input, item->value.pszVal, count, &bytesread);
|
||||
if (bytesread != count) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.pszVal);
|
||||
CoTaskMemFree(item->value.pszVal);
|
||||
return hr;
|
||||
}
|
||||
item->value.pszVal[count] = 0;
|
||||
|
@ -962,7 +962,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
break;
|
||||
}
|
||||
|
||||
item->value.blob.pBlobData = HeapAlloc(GetProcessHeap(), 0, count);
|
||||
item->value.blob.pBlobData = CoTaskMemAlloc(count);
|
||||
if (!item->value.blob.pBlobData) return E_OUTOFMEMORY;
|
||||
|
||||
item->value.blob.cbSize = count;
|
||||
|
@ -978,14 +978,14 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
|
|||
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.blob.pBlobData);
|
||||
CoTaskMemFree(item->value.blob.pBlobData);
|
||||
return hr;
|
||||
}
|
||||
hr = IStream_Read(input, item->value.blob.pBlobData, count, &bytesread);
|
||||
if (bytesread != count) hr = E_FAIL;
|
||||
if (hr != S_OK)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, item->value.blob.pBlobData);
|
||||
CoTaskMemFree(item->value.blob.pBlobData);
|
||||
return hr;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "objbase.h"
|
||||
#include "shlwapi.h"
|
||||
|
||||
#include "wincodecs_private.h"
|
||||
|
||||
|
@ -63,14 +64,14 @@ static HRESULT LoadTextMetadata(IStream *stream, const GUID *preferred_vendor,
|
|||
value_len = data_size - name_len - 1;
|
||||
|
||||
result = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MetadataItem));
|
||||
name = HeapAlloc(GetProcessHeap(), 0, name_len + 1);
|
||||
value = HeapAlloc(GetProcessHeap(), 0, value_len + 1);
|
||||
name = CoTaskMemAlloc(name_len + 1);
|
||||
value = CoTaskMemAlloc(value_len + 1);
|
||||
if (!result || !name || !value)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
HeapFree(GetProcessHeap(), 0, result);
|
||||
HeapFree(GetProcessHeap(), 0, name);
|
||||
HeapFree(GetProcessHeap(), 0, value);
|
||||
CoTaskMemFree(name);
|
||||
CoTaskMemFree(value);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -131,11 +132,11 @@ static HRESULT LoadGamaMetadata(IStream *stream, const GUID *preferred_vendor,
|
|||
HeapFree(GetProcessHeap(), 0, data);
|
||||
|
||||
result = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MetadataItem));
|
||||
name = HeapAlloc(GetProcessHeap(), 0, sizeof(L"ImageGamma"));
|
||||
SHStrDupW(L"ImageGamma", &name);
|
||||
if (!result || !name)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, result);
|
||||
HeapFree(GetProcessHeap(), 0, name);
|
||||
CoTaskMemFree(name);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -143,8 +144,6 @@ static HRESULT LoadGamaMetadata(IStream *stream, const GUID *preferred_vendor,
|
|||
PropVariantInit(&result[0].id);
|
||||
PropVariantInit(&result[0].value);
|
||||
|
||||
memcpy(name, L"ImageGamma", sizeof(L"ImageGamma"));
|
||||
|
||||
result[0].id.vt = VT_LPWSTR;
|
||||
result[0].id.pwszVal = name;
|
||||
result[0].value.vt = VT_UI4;
|
||||
|
@ -200,14 +199,14 @@ static HRESULT LoadChrmMetadata(IStream *stream, const GUID *preferred_vendor,
|
|||
result = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MetadataItem)*8);
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
dyn_names[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(lstrlenW(names[i])+1));
|
||||
SHStrDupW(names[i], &dyn_names[i]);
|
||||
if (!dyn_names[i]) break;
|
||||
}
|
||||
if (!result || i < 8)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, result);
|
||||
for (i=0; i<8; i++)
|
||||
HeapFree(GetProcessHeap(), 0, dyn_names[i]);
|
||||
CoTaskMemFree(dyn_names[i]);
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
@ -219,7 +218,6 @@ static HRESULT LoadChrmMetadata(IStream *stream, const GUID *preferred_vendor,
|
|||
PropVariantInit(&result[i].id);
|
||||
result[i].id.vt = VT_LPWSTR;
|
||||
result[i].id.pwszVal = dyn_names[i];
|
||||
lstrcpyW(dyn_names[i], names[i]);
|
||||
|
||||
PropVariantInit(&result[i].value);
|
||||
result[i].value.vt = VT_UI4;
|
||||
|
|
Loading…
Add table
Reference in a new issue