Dylan Smith : d3dxof: GetName can be used to just get the name length.
Alexandre Julliard
julliard at winehq.org
Thu Apr 21 11:17:49 CDT 2011
Module: wine
Branch: master
Commit: 8cae5c23121ffbf76cce42947ac22a30f3b1f369
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8cae5c23121ffbf76cce42947ac22a30f3b1f369
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Wed Apr 20 16:20:53 2011 -0400
d3dxof: GetName can be used to just get the name length.
---
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)
More information about the wine-cvs
mailing list