From: Marcus Meissner Subject: [PATCH] cmd: lastPath is either NULL or not (Coverity) Message-Id: <1414860045-29338-1-git-send-email-marcus@jet.franken.de> Date: Sat, 1 Nov 2014 17:40:45 +0100 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