Skip to content

Commit 7a19622

Browse files
committed
fix crash if ExternalViewers only has CommandLine (fixes #2691)
1 parent 7ae1fe4 commit 7a19622

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Menu.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,18 +1156,15 @@ static void AppendExternalViewersToMenu(HMENU menuFile, const WCHAR* filePath) {
11561156
}
11571157

11581158
WCHAR* name = ToWstrTemp(ev->name);
1159-
if (str::EmptyOrWhiteSpaceOnly(ev->name)) {
1159+
if (!ev->name || str::EmptyOrWhiteSpaceOnly(ev->name)) {
11601160
CmdLineArgsIter args(ToWstrTemp(ev->commandLine));
1161-
int nArgs = args.nArgs - 2;
1162-
if (nArgs <= 0) {
1161+
int nArgs = args.nArgs;
1162+
if (nArgs < 1) {
11631163
continue;
11641164
}
1165-
WCHAR* arg0 = args.at(2 + 0);
1166-
name = str::DupTemp(path::GetBaseNameTemp(arg0));
1167-
WCHAR* ext = (WCHAR*)path::GetExtTemp(name);
1168-
if (ext) {
1169-
*ext = 0;
1170-
}
1165+
WCHAR* exePath = args.at(0);
1166+
const WCHAR* exeName = path::GetBaseNameTemp(exePath);
1167+
name = str::DupTemp(exeName);
11711168
}
11721169

11731170
AutoFreeWstr menuString(str::Format(_TR("Open in %s"), name));

0 commit comments

Comments
 (0)