[WINDOWSCODECS] Sync with Wine 3.0. CORE-14225
[reactos.git] / dll / win32 / windowscodecs / metadatahandler.c
index 25f4314..dff5ed3 100644 (file)
@@ -704,7 +704,7 @@ static int tag_to_vt(SHORT tag)
 static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
                               MetadataItem *item, BOOL native_byte_order)
 {
-    ULONG count, value, i;
+    ULONG count, value, i, bytesread;
     SHORT type;
     LARGE_INTEGER pos;
     HRESULT hr;
@@ -746,7 +746,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
 
         item->value.vt |= VT_VECTOR;
         item->value.u.caub.cElems = count;
-        item->value.u.caub.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
+        item->value.u.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count);
         if (!item->value.u.caub.pElems) return E_OUTOFMEMORY;
 
         pos.QuadPart = value;
@@ -756,8 +756,9 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             HeapFree(GetProcessHeap(), 0, item->value.u.caub.pElems);
             return hr;
         }
-        hr = IStream_Read(input, item->value.u.caub.pElems, count, NULL);
-        if (FAILED(hr))
+        hr = IStream_Read(input, item->value.u.caub.pElems, count, &bytesread);
+        if (bytesread != count) hr = E_FAIL;
+        if (hr != S_OK)
         {
             HeapFree(GetProcessHeap(), 0, item->value.u.caub.pElems);
             return hr;
@@ -790,7 +791,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
 
         item->value.vt |= VT_VECTOR;
         item->value.u.caui.cElems = count;
-        item->value.u.caui.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 2);
+        item->value.u.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2);
         if (!item->value.u.caui.pElems) return E_OUTOFMEMORY;
 
         pos.QuadPart = value;
@@ -800,8 +801,9 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             HeapFree(GetProcessHeap(), 0, item->value.u.caui.pElems);
             return hr;
         }
-        hr = IStream_Read(input, item->value.u.caui.pElems, count * 2, NULL);
-        if (FAILED(hr))
+        hr = IStream_Read(input, item->value.u.caui.pElems, count * 2, &bytesread);
+        if (bytesread != count * 2) hr = E_FAIL;
+        if (hr != S_OK)
         {
             HeapFree(GetProcessHeap(), 0, item->value.u.caui.pElems);
             return hr;
@@ -822,7 +824,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
 
         item->value.vt |= VT_VECTOR;
         item->value.u.caul.cElems = count;
-        item->value.u.caul.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 4);
+        item->value.u.caul.pElems = HeapAlloc(GetProcessHeap(), 0, count * 4);
         if (!item->value.u.caul.pElems) return E_OUTOFMEMORY;
 
         pos.QuadPart = value;
@@ -832,8 +834,9 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             HeapFree(GetProcessHeap(), 0, item->value.u.caul.pElems);
             return hr;
         }
-        hr = IStream_Read(input, item->value.u.caul.pElems, count * 4, NULL);
-        if (FAILED(hr))
+        hr = IStream_Read(input, item->value.u.caul.pElems, count * 4, &bytesread);
+        if (bytesread != count * 4) hr = E_FAIL;
+        if (hr != S_OK)
         {
             HeapFree(GetProcessHeap(), 0, item->value.u.caul.pElems);
             return hr;
@@ -859,7 +862,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             hr = IStream_Seek(input, pos, SEEK_SET, NULL);
             if (FAILED(hr)) return hr;
 
-            hr = IStream_Read(input, &ull, sizeof(ull), NULL);
+            hr = IStream_Read(input, &ull, sizeof(ull), &bytesread);
+            if (bytesread != sizeof(ull)) hr = E_FAIL;
             if (hr != S_OK) return hr;
 
             item->value.u.uhVal.QuadPart = ull;
@@ -877,7 +881,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
         {
             item->value.vt |= VT_VECTOR;
             item->value.u.cauh.cElems = count;
-            item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 8);
+            item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), 0, count * 8);
             if (!item->value.u.cauh.pElems) return E_OUTOFMEMORY;
 
             pos.QuadPart = value;
@@ -887,8 +891,9 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
                 HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems);
                 return hr;
             }
-            hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, NULL);
-            if (FAILED(hr))
+            hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, &bytesread);
+            if (bytesread != count * 8) hr = E_FAIL;
+            if (hr != S_OK)
             {
                 HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems);
                 return hr;
@@ -906,7 +911,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
         }
         break;
     case IFD_ASCII:
-        item->value.u.pszVal = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count + 1);
+        item->value.u.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1);
         if (!item->value.u.pszVal) return E_OUTOFMEMORY;
 
         if (count <= 4)
@@ -924,8 +929,9 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             HeapFree(GetProcessHeap(), 0, item->value.u.pszVal);
             return hr;
         }
-        hr = IStream_Read(input, item->value.u.pszVal, count, NULL);
-        if (FAILED(hr))
+        hr = IStream_Read(input, item->value.u.pszVal, count, &bytesread);
+        if (bytesread != count) hr = E_FAIL;
+        if (hr != S_OK)
         {
             HeapFree(GetProcessHeap(), 0, item->value.u.pszVal);
             return hr;
@@ -940,7 +946,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             break;
         }
 
-        item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
+        item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), 0, count);
         if (!item->value.u.blob.pBlobData) return E_OUTOFMEMORY;
 
         item->value.u.blob.cbSize = count;
@@ -959,8 +965,9 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
             HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData);
             return hr;
         }
-        hr = IStream_Read(input, item->value.u.blob.pBlobData, count, NULL);
-        if (FAILED(hr))
+        hr = IStream_Read(input, item->value.u.blob.pBlobData, count, &bytesread);
+        if (bytesread != count) hr = E_FAIL;
+        if (hr != S_OK)
         {
             HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData);
             return hr;