Improve stability of shell32 debugging
Dmitry Timoshkov
dmitry at baikal.ru
Thu Sep 8 06:27:48 CDT 2005
Hello,
this patch should improve stability of shell32 debugging.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
- stop using a not initialized variable szTemp in _dbg_ILSimpleGetText,
make _dbg_ILSimpleGetText return no value since nobody is using it;
- stop dereferencing a possible NULL in pdump since _dbg_ILGetDataPointer
can potentially return NULL (for instance for root or desktop pidl).
- make shdebugstr_guid use standard wine_dbg_sprintf instead of the
handmade solution.
diff -up cvs/hq/wine/dlls/shell32/debughlp.c wine/dlls/shell32/debughlp.c
--- cvs/hq/wine/dlls/shell32/debughlp.c 2005-08-12 13:22:41.000000000 +0900
+++ wine/dlls/shell32/debughlp.c 2005-09-08 20:15:35.000000000 +0900
@@ -144,14 +144,12 @@ IID* _dbg_ILGetGUIDPointer(LPCITEMIDLIST
}
static
-DWORD _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
+void _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
{
- DWORD dwReturn=0;
LPSTR szSrc;
GUID const * riid;
- char szTemp[MAX_PATH];
- if (!pidl) return 0;
+ if (!pidl) return;
if (szOut)
*szOut = 0;
@@ -160,13 +158,11 @@ DWORD _dbg_ILSimpleGetText (LPCITEMIDLIS
{
/* desktop */
if (szOut) lstrcpynA(szOut, "Desktop", uOutSize);
- dwReturn = strlen ("Desktop");
}
else if (( szSrc = _dbg_ILGetTextPointer(pidl) ))
{
/* filesystem */
if (szOut) lstrcpynA(szOut, szSrc, uOutSize);
- dwReturn = strlen(szSrc);
}
else if (( riid = _dbg_ILGetGUIDPointer(pidl) ))
{
@@ -175,9 +171,7 @@ DWORD _dbg_ILSimpleGetText (LPCITEMIDLIS
riid->Data1, riid->Data2, riid->Data3,
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
- dwReturn = strlen (szTemp);
}
- return dwReturn;
}
@@ -202,17 +196,18 @@ void pdump (LPCITEMIDLIST pidl)
{
DWORD dwAttrib = 0;
LPPIDLDATA pData = _dbg_ILGetDataPointer(pidltemp);
- DWORD type = pData->type;
+ DWORD type = pData ? pData->type : 0;;
LPSTR szLongName = _dbg_ILGetTextPointer(pidltemp);
LPSTR szShortName = _dbg_ILGetSTextPointer(pidltemp);
char szName[MAX_PATH];
_dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH);
- if( PT_FOLDER == type || PT_VALUE == type)
+ if ( pData && (PT_FOLDER == type || PT_VALUE == type) )
dwAttrib = pData->u.file.uFileAttribs;
- MESSAGE ("[%p] size=%04u type=%lx attr=0x%08lx name=\"%s\" (%s,%s)\n",
- pidltemp, pidltemp->mkid.cb,type,dwAttrib,szName,debugstr_a(szLongName), debugstr_a(szShortName));
+ MESSAGE ("[%p] size=%04u type=%lx attr=0x%08lx name=%s (%s,%s)\n",
+ pidltemp, pidltemp->mkid.cb, type, dwAttrib,
+ debugstr_a(szName), debugstr_a(szLongName), debugstr_a(szShortName));
pidltemp = _dbg_ILGetNext(pidltemp);
@@ -290,11 +285,7 @@ BOOL pcheck( LPCITEMIDLIST pidl )
return TRUE;
}
-static char shdebugstr_buf1[100];
-static char shdebugstr_buf2[100];
-static char * shdebugstr_buf = shdebugstr_buf1;
-
-static struct {
+static const struct {
REFIID riid;
const char *name;
} InterfaceDesc[] = {
@@ -328,11 +319,8 @@ const char * shdebugstr_guid( const stru
const char* name = NULL;
char clsidbuf[100];
- shdebugstr_buf = (shdebugstr_buf == shdebugstr_buf1) ? shdebugstr_buf2 : shdebugstr_buf1;
+ if (!id) return "(null)";
- if (!id) {
- strcpy (shdebugstr_buf, "(null)");
- } else {
for (i=0;InterfaceDesc[i].riid && !name;i++) {
if (IsEqualIID(InterfaceDesc[i].riid, id)) name = InterfaceDesc[i].name;
}
@@ -341,10 +329,8 @@ const char * shdebugstr_guid( const stru
name = clsidbuf;
}
- sprintf( shdebugstr_buf, "\n\t{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x} (%s)",
+ return wine_dbg_sprintf( "\n\t{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x} (%s)",
id->Data1, id->Data2, id->Data3,
id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7], name ? name : "unknown" );
- }
- return shdebugstr_buf;
}
More information about the wine-patches
mailing list