Sven Baars (@sbaars) commented about dlls/shell32/shlview_cmenu.c:
+ do { + WCHAR *link_filename; + + if (counter == 1) + { + static const WCHAR *fmt = L"%s - %s.lnk"; + int length = wcslen(filename) + wcslen(shortcutW) + 7; /* length of the format*/ + link_filename = malloc((length + 1) * sizeof(WCHAR)); + wsprintfW(link_filename, fmt, filename, shortcutW); + } + else + { + static const WCHAR *fmt = L"%s - %s (%s).lnk"; + int length = wcslen(filename) + wcslen(shortcutW) + 10; /* length of the format*/ + WCHAR counter_string[34]; + wsprintfW(counter_string, L"%i", counter); I think we can just allocate a sufficient amount for `link_filename` and add the counter directly in the `wsprintfW` call below.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/5373#note_121805