cmd: Only copy from existent string (Coverity)
André Hentschel
nerv at dawncrow.de
Mon Jan 2 20:54:28 CST 2012
CID: 510
---
programs/cmd/wcmdmain.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 67a524d..579a49c 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1043,13 +1043,15 @@ void WCMD_run_program (WCHAR *command, int called) {
/* Convert eg. ..\fred to include a directory by removing file part */
GetFullPathNameW(param1, sizeof(pathtosearch)/sizeof(WCHAR), pathtosearch, NULL);
- lastSlash = strrchrW(pathtosearch, '\\');
- if (lastSlash && strchrW(lastSlash, '.') != NULL) extensionsupplied = TRUE;
- strcpyW(stemofsearch, lastSlash+1);
+ if ((lastSlash = strrchrW(pathtosearch, '\\')))
+ {
+ 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 */
- if (lastSlash) *(lastSlash + 1) = 0x00;
+ /* Reduce pathtosearch to a path with trailing '\' to support c:\a.bat and
+ c:\windows\a.bat syntax */
+ *(lastSlash + 1) = 0x00;
+ }
}
/* Now extract PATHEXT */
--
Best Regards, André Hentschel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Nachrichtenteil als Anhang
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20120103/e0381666/attachment-0001.ksh>
More information about the wine-patches
mailing list