mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 05:21:08 +00:00
shlwapi: Don't crash in PathStripPath when read-only string is passed and it's not modified.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c1a46db98b
commit
31c49c2851
|
@ -661,7 +661,7 @@ void WINAPI PathStripPathA(LPSTR lpszPath)
|
|||
if (lpszPath)
|
||||
{
|
||||
LPSTR lpszFileName = PathFindFileNameA(lpszPath);
|
||||
if(lpszFileName)
|
||||
if(lpszFileName != lpszPath)
|
||||
RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)+1);
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ void WINAPI PathStripPathW(LPWSTR lpszPath)
|
|||
|
||||
TRACE("(%s)\n", debugstr_w(lpszPath));
|
||||
lpszFileName = PathFindFileNameW(lpszPath);
|
||||
if(lpszFileName)
|
||||
if(lpszFileName != lpszPath)
|
||||
RtlMoveMemory(lpszPath, lpszFileName, (strlenW(lpszFileName)+1)*sizeof(WCHAR));
|
||||
}
|
||||
|
||||
|
|
|
@ -1639,6 +1639,19 @@ static void test_PathIsRelativeW(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_PathStripPathA(void)
|
||||
{
|
||||
const char const_path[] = "test";
|
||||
char path[] = "short//path\\file.txt";
|
||||
|
||||
PathStripPathA(path);
|
||||
ok(!strcmp(path, "file.txt"), "path = %s\n", path);
|
||||
|
||||
/* following test should not crash */
|
||||
/* LavView 2013 depends on that behaviour */
|
||||
PathStripPathA((char*)const_path);
|
||||
}
|
||||
|
||||
START_TEST(path)
|
||||
{
|
||||
HMODULE hShlwapi = GetModuleHandleA("shlwapi.dll");
|
||||
|
@ -1684,4 +1697,5 @@ START_TEST(path)
|
|||
test_PathUnExpandEnvStrings();
|
||||
test_PathIsRelativeA();
|
||||
test_PathIsRelativeW();
|
||||
test_PathStripPathA();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue