d3dxof: GetName can be used to just get the name length.
Dylan Smith
dylan.ah.smith at gmail.com
Wed Apr 20 15:20:53 CDT 2011
This behaviour is documented on msdn and tested to work on native d3dxof.
---
dlls/d3dxof/d3dxof.c | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c
index 51fc14b..7e3eb9e 100644
--- a/dlls/d3dxof/d3dxof.c
+++ b/dlls/d3dxof/d3dxof.c
@@ -728,13 +728,23 @@ static HRESULT WINAPI IDirectXFileDataImpl_GetName(IDirectXFileData* iface, LPST
{
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
+ DWORD len;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
- if (!pstrNameBuf)
+ if (!pdwBufLen)
return DXFILEERR_BADVALUE;
- strcpy(pstrNameBuf, This->pobj->name);
+ len = strlen(This->pobj->name);
+ if (len)
+ len++;
+
+ if (pstrNameBuf) {
+ if (*pdwBufLen < len)
+ return DXFILEERR_BADVALUE;
+ CopyMemory(pstrNameBuf, This->pobj->name, len);
+ }
+ *pdwBufLen = len;
return DXFILE_OK;
}
@@ -962,15 +972,25 @@ static ULONG WINAPI IDirectXFileDataReferenceImpl_Release(IDirectXFileDataRefere
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
{
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
+ DWORD len;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
- if (!pstrNameBuf)
+ if (!pdwBufLen)
return DXFILEERR_BADVALUE;
- strcpy(pstrNameBuf, This->ptarget->name);
+ len = strlen(This->ptarget->name);
+ if (len)
+ len++;
- return DXFILEERR_BADVALUE;
+ if (pstrNameBuf) {
+ if (*pdwBufLen < len)
+ return DXFILEERR_BADVALUE;
+ CopyMemory(pstrNameBuf, This->ptarget->name, len);
+ }
+ *pdwBufLen = len;
+
+ return DXFILE_OK;
}
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference* iface, LPGUID pGuid)
--
1.7.2.5
More information about the wine-patches
mailing list