Vincent Povirk : windowscodecs: Accept failure when seeking to the start of a TGA footer.

Alexandre Julliard julliard at winehq.org
Tue Jan 11 10:08:26 CST 2011


Module: wine
Branch: master
Commit: f4ef7ff48ae9b5decaddd5f2be9856466bfe01af
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f4ef7ff48ae9b5decaddd5f2be9856466bfe01af

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Jan 10 17:13:02 2011 -0600

windowscodecs: Accept failure when seeking to the start of a TGA footer.

---

 dlls/windowscodecs/tgaformat.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/dlls/windowscodecs/tgaformat.c b/dlls/windowscodecs/tgaformat.c
index 14510cf..8db1cf1 100644
--- a/dlls/windowscodecs/tgaformat.c
+++ b/dlls/windowscodecs/tgaformat.c
@@ -284,25 +284,32 @@ static HRESULT WINAPI TgaDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
     /* Read footer if there is one */
     seek.QuadPart = -sizeof(tga_footer);
     hr = IStream_Seek(pIStream, seek, STREAM_SEEK_END, NULL);
-    if (FAILED(hr)) goto end;
 
-    hr = IStream_Read(pIStream, &footer, sizeof(tga_footer), &bytesread);
-    if (SUCCEEDED(hr) && bytesread != sizeof(tga_footer))
-    {
-        TRACE("got only %u footer bytes\n", bytesread);
-        hr = E_FAIL;
-    }
-    if (FAILED(hr)) goto end;
+    if (SUCCEEDED(hr)) {
+        hr = IStream_Read(pIStream, &footer, sizeof(tga_footer), &bytesread);
+        if (SUCCEEDED(hr) && bytesread != sizeof(tga_footer))
+        {
+            TRACE("got only %u footer bytes\n", bytesread);
+            hr = E_FAIL;
+        }
 
-    if (memcmp(footer.magic, tga_footer_magic, sizeof(tga_footer_magic)) == 0)
-    {
-        This->extension_area_offset = footer.extension_area_offset;
-        This->developer_directory_offset = footer.developer_directory_offset;
+        if (memcmp(footer.magic, tga_footer_magic, sizeof(tga_footer_magic)) == 0)
+        {
+            This->extension_area_offset = footer.extension_area_offset;
+            This->developer_directory_offset = footer.developer_directory_offset;
+        }
+        else
+        {
+            This->extension_area_offset = 0;
+            This->developer_directory_offset = 0;
+        }
     }
     else
     {
+        /* File is too small to have a footer. */
         This->extension_area_offset = 0;
         This->developer_directory_offset = 0;
+        hr = S_OK;
     }
 
     if (This->extension_area_offset)




More information about the wine-cvs mailing list