Skip to content

Commit

Permalink
Fix crash on break on invalid filename
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Jan 10, 2025
1 parent 266394e commit 4b5af12
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions breakpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,12 @@ BreakpointManager::ParseBreakpointLine(const std::string& input, std::string* fi
std::string partial_filename = input.substr(0, sep_offs);
// the user may have given a partial filename (e.g. without a path), so
// walk through all files to find a match
*filename = debugger_->FindFileByPartialName(partial_filename);
if ((*filename).empty()) {
const char* found_filename = debugger_->FindFileByPartialName(partial_filename);
if (!found_filename) {
std::cout << "Invalid filename.\n";
return "";
}
*filename = found_filename;
return input.substr(sep_offs + 1);
}
return input;
Expand Down
2 changes: 1 addition & 1 deletion debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Debugger::DumpStack()
context_->DestroyFrameIterator(frames);
}

std::string
const char*
Debugger::FindFileByPartialName(const std::string partialname)
{
// the user may have given a partial filename (e.g. without a path), so
Expand Down
2 changes: 1 addition & 1 deletion debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Debugger {

void DumpStack();
void PrintCurrentPosition();
std::string FindFileByPartialName(const std::string partialname);
const char* FindFileByPartialName(const std::string partialname);

private:
std::shared_ptr<DebuggerCommand> ResolveCommandString(const std::string command);
Expand Down

0 comments on commit 4b5af12

Please sign in to comment.