From f9c9ea6343daf1fbd587d4718b48371ad1bef5a3 Mon Sep 17 00:00:00 2001 From: Carlo Bramini Date: Mon, 9 Apr 2012 23:55:53 +0200 Subject: [PATCH] shlwapi: Don't remove nonexistent extension in PathRemoveExtension. --- dlls/shlwapi/path.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index 92a830bd50c..6f09d228259 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -760,6 +760,10 @@ void WINAPI PathRemoveArgsW(LPWSTR lpszPath) * PARAMS * lpszPath [I/O] Path to remove the extension from * + * NOTES + * The NUL terminator must be written only if extension exists + * and if the pointed character is not already NUL. + * * RETURNS * Nothing. */ @@ -770,7 +774,8 @@ void WINAPI PathRemoveExtensionA(LPSTR lpszPath) if (lpszPath) { lpszPath = PathFindExtensionA(lpszPath); - *lpszPath = '\0'; + if (lpszPath && *lpszPath != '\0') + *lpszPath = '\0'; } } @@ -786,7 +791,8 @@ void WINAPI PathRemoveExtensionW(LPWSTR lpszPath) if (lpszPath) { lpszPath = PathFindExtensionW(lpszPath); - *lpszPath = '\0'; + if (lpszPath && *lpszPath != '\0') + *lpszPath = '\0'; } }