Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the use of substr from bsg_check_invalid_libname #1961

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ static void bsg_fallback_symbols(const uint64_t addr,
}

static bool bsg_check_invalid_libname(const std::string &filename) {
const auto length = filename.length();
// turn clang-format off - for clarity in the string compare:
// clang-format off
return filename.empty() ||
// if the filename ends-in ".apk" then the lib was loaded without
// extracting it from the apk we consider these as "invalid" to trigger
// the use of a fallback filename
(filename.length() >= 4 &&
filename.substr(filename.length() - 4, 4) == ".apk");
(length >= 4 &&
// compare char-by-char to avoid the allocation is substr
filename[length - 4] == '.' &&
filename[length - 3] == 'a' &&
filename[length - 2] == 'p' &&
filename[length - 1] == 'k');
// clang-format on
}

void bsg_unwinder_init() {
Expand Down
Loading