Skip to content

Commit

Permalink
fix crash if ExternalViewers only has CommandLine (fixes #2691)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Jun 7, 2022
1 parent 7ae1fe4 commit 7a19622
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,18 +1156,15 @@ static void AppendExternalViewersToMenu(HMENU menuFile, const WCHAR* filePath) {
}

WCHAR* name = ToWstrTemp(ev->name);
if (str::EmptyOrWhiteSpaceOnly(ev->name)) {
if (!ev->name || str::EmptyOrWhiteSpaceOnly(ev->name)) {
CmdLineArgsIter args(ToWstrTemp(ev->commandLine));
int nArgs = args.nArgs - 2;
if (nArgs <= 0) {
int nArgs = args.nArgs;
if (nArgs < 1) {
continue;
}
WCHAR* arg0 = args.at(2 + 0);
name = str::DupTemp(path::GetBaseNameTemp(arg0));
WCHAR* ext = (WCHAR*)path::GetExtTemp(name);
if (ext) {
*ext = 0;
}
WCHAR* exePath = args.at(0);
const WCHAR* exeName = path::GetBaseNameTemp(exePath);
name = str::DupTemp(exeName);
}

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

0 comments on commit 7a19622

Please sign in to comment.