[PATCH 0/1] MR1041: shell32: Introduce combine_path helper for DDE.
Split from merge request !23 per Huw's suggestion -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1041
From: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/shell32/dde.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/dlls/shell32/dde.c b/dlls/shell32/dde.c index 5ab63136092..c8b1f0280cd 100644 --- a/dlls/shell32/dde.c +++ b/dlls/shell32/dde.c @@ -78,20 +78,30 @@ static inline BOOL Dde_OnWildConnect(HSZ hszTopic, HSZ hszService) return FALSE; } +static WCHAR *combine_path(const WCHAR *directory, const WCHAR *name, const WCHAR *extension) +{ + WCHAR *path; + int len; + + len = wcslen(directory) + 1 + wcslen(name); + if (extension) len += wcslen(extension); + path = heap_alloc((len + 1) * sizeof(WCHAR)); + + PathCombineW(path, directory, name); + + if (extension) + wcscat(path, extension); + + return path; +} + /* Returned string must be freed by caller */ static WCHAR *get_programs_path(const WCHAR *name) { WCHAR *programs, *path; - int len; SHGetKnownFolderPath(&FOLDERID_Programs, 0, NULL, &programs); - - len = lstrlenW(programs) + 1 + lstrlenW(name); - path = heap_alloc((len + 1) * sizeof(*path)); - lstrcpyW(path, programs); - lstrcatW(path, L"/"); - lstrcatW(path, name); - + path = combine_path(programs, name, NULL); CoTaskMemFree(programs); return path; @@ -252,16 +262,14 @@ static DWORD PROGMAN_OnExecute(WCHAR *command, int argc, WCHAR **argv) } if (argc >= 2) { - len = lstrlenW(last_group) + 1 + lstrlenW(argv[1]) + 5; - name = heap_alloc(len * sizeof(*name)); - swprintf( name, len, L"%s/%s.lnk", last_group, argv[1] ); + name = combine_path(last_group, argv[1], L".lnk"); } else { - const WCHAR *filename = PathFindFileNameW(argv[0]); - len = PathFindExtensionW(filename) - filename; - name = heap_alloc((lstrlenW(last_group) + 1 + len + 5) * sizeof(*name)); - swprintf( name, lstrlenW(last_group) + 1 + len + 5, L"%s/%.*s.lnk", last_group, len, filename ); + WCHAR *filename = wcsdup(PathFindFileNameW(argv[0])); + *PathFindExtensionW(filename) = '\0'; + name = combine_path(last_group, filename, L".lnk"); + heap_free(filename); } hres = IPersistFile_Save(file, name, TRUE); @@ -278,12 +286,8 @@ static DWORD PROGMAN_OnExecute(WCHAR *command, int argc, WCHAR **argv) if (argc < 1) return DDE_FNOTPROCESSED; - len = lstrlenW(last_group) + 1 + lstrlenW(argv[0]) + 5; - name = heap_alloc(len * sizeof(*name)); - swprintf( name, len, L"%s/%s.lnk", last_group, argv[0]); - + name = combine_path(last_group, argv[0], L".lnk"); ret = DeleteFileW(name); - heap_free(name); if (!ret) return DDE_FNOTPROCESSED; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1041
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=124919 Your paranoid android. === debian11 (32 bit zh:CN report) === shell32: autocomplete.c:614: Test failed: Expected (null), got L"ab" autocomplete.c:637: Test failed: Expected (null), got L"www.ax" === debian11 (build log) === Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24822. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24822. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24822.
I didn't mean for this to be a separate MR, just a separate commit in the original MR. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1041#note_10406
Sorry, I thought you meant that the allocation cleanup alone would be more likely to be accepted than the sanitization code, which would have meant that it needed a separate MR. I just updated the original MR to have both commits. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1041#note_10415
This merge request was closed by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1041
participants (4)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Huw Davies (@huw) -
Marvin