[PATCH] cmd: lastPath is either NULL or not (Coverity)
Marcus Meissner
marcus at jet.franken.de
Sat Nov 1 11:40:45 CDT 2014
210510 Dereference after null check
---
programs/cmd/wcmdmain.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index e5865e6..4ac2715 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1080,12 +1080,17 @@ void WCMD_run_program (WCHAR *command, BOOL called)
/* Convert eg. ..\fred to include a directory by removing file part */
GetFullPathNameW(firstParam, sizeof(pathtosearch)/sizeof(WCHAR), pathtosearch, NULL);
lastSlash = strrchrW(pathtosearch, '\\');
- if (lastSlash && strchrW(lastSlash, '.') != NULL) extensionsupplied = TRUE;
- strcpyW(stemofsearch, lastSlash+1);
-
- /* Reduce pathtosearch to a path with trailing '\' to support c:\a.bat and
- c:\windows\a.bat syntax */
- if (lastSlash) *(lastSlash + 1) = 0x00;
+ if (lastSlash)
+ {
+ if (strchrW(lastSlash, '.') != NULL) extensionsupplied = TRUE;
+ strcpyW(stemofsearch, lastSlash+1);
+ /* Reduce pathtosearch to a path with trailing '\' to support c:\a.bat and
+ c:\windows\a.bat syntax */
+ *(lastSlash + 1) = 0x00;
+ } else {
+ WINE_FIXME("getfullpathname returned a path %s without slash?\n", pathtosearch);
+ strcpyW(stemofsearch, pathtosearch);
+ }
}
/* Now extract PATHEXT */
--
1.8.4.5
More information about the wine-patches
mailing list