Skip to content

Commit

Permalink
Fix a nullptr dereference in dbglistprocesses. Thanks to @HydrophonePia!
Browse files Browse the repository at this point in the history
Closes #3075
  • Loading branch information
mrexodia committed Apr 27, 2023
1 parent 1845952 commit a811063
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/dbg/commands/cmd-script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ bool cbScriptCmd(int argc, char* argv[])
if(IsArgumentsLessThan(argc, 2))
return false;
auto scriptcmd = strchr(argv[0], ' ');
if(scriptcmd == nullptr)
return false;
while(isspace(*scriptcmd))
scriptcmd++;
return scriptcmdexec(scriptcmd);
Expand Down
3 changes: 2 additions & 1 deletion src/dbg/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2320,7 +2320,8 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* infoList, std::vector<std::st
Memory<char*> basicName(strlen(exeName) + 1, "dbglistprocesses:basicName");
strncpy_s(basicName(), sizeof(char) * strlen(exeName) + 1, exeName, _TRUNCATE);
char* dotInName = strrchr(basicName(), '.');
dotInName[0] = '\0';
if(dotInName != nullptr)
dotInName[0] = '\0';
size_t basicNameLen = strlen(basicName());
peNameInCmd = strstr(cmdline, basicName());
//check for basic name is used in path to exe
Expand Down
4 changes: 3 additions & 1 deletion src/dbg/plugin_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,9 @@ void pluginmenuentrysethotkey(int pluginHandle, int hEntry, const char* hotkey)
{
char name[MAX_PATH] = "";
strcpy_s(name, plugin.plugname);
*strrchr(name, '.') = '\0';
auto dot = strrchr(name, '.');
if(dot != nullptr)
*dot = '\0';
auto hack = StringUtils::sprintf("%s\1%s_%d", hotkey, name, hEntry);
GuiMenuSetEntryHotkey(currentMenu.hEntryMenu, hack.c_str());
break;
Expand Down

0 comments on commit a811063

Please sign in to comment.