Christian Costa : d3dxof: Fix IDirectXFileDataImpl_GetName and IDirectXFileDataReferenceImpl_GetName + tests .

Alexandre Julliard julliard at winehq.org
Thu May 16 13:55:06 CDT 2013


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

Author: Christian Costa <titan.costa at gmail.com>
Date:   Thu May 16 01:28:46 2013 +0200

d3dxof: Fix IDirectXFileDataImpl_GetName and IDirectXFileDataReferenceImpl_GetName + tests.

---

 dlls/d3dxof/d3dxof.c       |    6 ++++++
 dlls/d3dxof/tests/d3dxof.c |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c
index 498b192..7090141 100644
--- a/dlls/d3dxof/d3dxof.c
+++ b/dlls/d3dxof/d3dxof.c
@@ -587,6 +587,9 @@ static HRESULT WINAPI IDirectXFileDataImpl_GetName(IDirectXFileData* iface, LPST
     if (*pdwBufLen < len)
       return DXFILEERR_BADVALUE;
     CopyMemory(pstrNameBuf, This->pobj->name, len);
+    /* Even if we return a size of 0, an empty string with a null byte must be returned */
+    if (*pdwBufLen && !len)
+      pstrNameBuf[0] = 0;
   }
   *pdwBufLen = len;
 
@@ -851,6 +854,9 @@ static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataRefe
     if (*pdwBufLen < len)
       return DXFILEERR_BADVALUE;
     CopyMemory(pstrNameBuf, This->ptarget->name, len);
+    /* Even if we return a size of 0, an empty string with a null byte must be returned */
+    if (*pdwBufLen && !len)
+      pstrNameBuf[0] = 0;
   }
   *pdwBufLen = len;
 
diff --git a/dlls/d3dxof/tests/d3dxof.c b/dlls/d3dxof/tests/d3dxof.c
index f6874a4..87b7985 100644
--- a/dlls/d3dxof/tests/d3dxof.c
+++ b/dlls/d3dxof/tests/d3dxof.c
@@ -546,10 +546,18 @@ static void test_getname(void)
     hr = IDirectXFileData_GetName(lpdxfd, NULL, &length);
     ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr);
     ok(length == 0, "Returned length should be 0 instead of %u\n", length);
+    length = 0;
+    name[0] = 0x7f;
+    hr = IDirectXFileData_GetName(lpdxfd, name, &length);
+    ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr);
+    ok(length == 0, "Returned length should be 0 instead of %u\n", length);
+    ok(name[0] == 0x7f, "First character is %#x instead of 0x7f\n", name[0]);
     length = sizeof(name);
+    name[0] = 0x7f;
     hr = IDirectXFileData_GetName(lpdxfd, name, &length);
     ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr);
     ok(length == 0, "Returned length should be 0 instead of %u\n", length);
+    ok(name[0] == 0, "First character is %#x instead of 0x00\n", name[0]);
 
     ref = IDirectXFileEnumObject_Release(lpdxfeo);
     ok(ref == 0, "Got refcount %d, expected 0\n", ref);




More information about the wine-cvs mailing list