Hans Leidekker (@hans) commented about dlls/shell32/shlexec.c:
wszApplicationName[len-2] = '\0'; TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName)); } else {
DWORD l = lstrlenW(sei_tmp.lpFile)+1;
DWORD l;
/* remove trailing spaces */
WCHAR *buf = wcsdup(sei->lpFile), *end = buf + wcslen( buf ) - 1;
while (end >= buf && *end == ' ') *end-- = 0;
sei_tmp.lpFile = buf;
l = lstrlenW(sei_tmp.lpFile)+1; if(l > dwApplicationNameLen) dwApplicationNameLen = l+1; wszApplicationName = malloc(dwApplicationNameLen * sizeof(WCHAR)); memcpy(wszApplicationName, sei_tmp.lpFile, l*sizeof(WCHAR));
free(buf);
Actually I meant that you can avoid the extra copy. Like this: ` } else { /* remove trailing spaces */ WCHAR *buf = wcsdup(sei->lpFile), *end = buf + wcslen( buf ) - 1; while (end >= buf && *end == ' ') *end-- = 0;
len = lstrlenW( buf ) + 1; if (len > dwApplicationNameLen) dwApplicationNameLen = len + 1; wszApplicationName = buf; } `