Just fancied a change. A simple testpgm shows windows allows a null psfi
because you can use it to quickly determine an exe type. Test shows both
the A and W versions should handle null pointers regardless of the size
value passed in.
Changelog
SHGetFileInfo should tollerate null pointers
Jason
Index: dlls/shell32/shell32_main.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.c,v
retrieving revision 1.115
diff -u -r1.115 shell32_main.c
--- dlls/shell32/shell32_main.c 13 May 2003 22:19:01 -0000 1.115
+++ dlls/shell32/shell32_main.c 19 Jun 2003 20:33:58 -0000
@@ -225,9 +225,11 @@
return FALSE;
/* windows initializes this values regardless of the flags */
- psfi->szDisplayName[0] = '\0';
- psfi->szTypeName[0] = '\0';
- psfi->iIcon = 0;
+ if (psfi != NULL) {
+ psfi->szDisplayName[0] = '\0';
+ psfi->szTypeName[0] = '\0';
+ psfi->iIcon = 0;
+ }
if (!(flags & SHGFI_PIDL)){
/* SHGitFileInfo should work with absolute and relative paths */
@@ -297,6 +299,9 @@
return 0;
}
+ /* psfi is NULL normally to query EXE type, if not none of the below makes
+ sense anyway. Windows allows this and just returns FALSE */
+ if (psfi != NULL) return FALSE;
/* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
* is not specified.
@@ -496,20 +501,20 @@
WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
}
- if(flags & SHGFI_ATTR_SPECIFIED)
+ if(psfi && (flags & SHGFI_ATTR_SPECIFIED))
temppsfi.dwAttributes=psfi->dwAttributes;
- ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
+ ret = SHGetFileInfoA(temppath, dwFileAttributes, (psfi == NULL)? NULL : &temppsfi, sizeof(temppsfi), flags);
- if(flags & SHGFI_ICON)
+ if(psfi && (flags & SHGFI_ICON))
psfi->hIcon=temppsfi.hIcon;
- if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
+ if(psfi && (flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION)))
psfi->iIcon=temppsfi.iIcon;
- if(flags & SHGFI_ATTRIBUTES)
+ if(psfi && (flags & SHGFI_ATTRIBUTES))
psfi->dwAttributes=temppsfi.dwAttributes;
- if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
+ if(psfi && (flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION)))
MultiByteToWideChar(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, sizeof(psfi->szDisplayName));
- if(flags & SHGFI_TYPENAME)
+ if(psfi && (flags & SHGFI_TYPENAME))
MultiByteToWideChar(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, sizeof(psfi->szTypeName));
if(!(flags & SHGFI_PIDL)) HeapFree(GetProcessHeap(), 0, temppath);