Skip to content

Commit

Permalink
fix(ndk): remove the use of substr from bsg_check_invalid_libname
Browse files Browse the repository at this point in the history
  • Loading branch information
lemnik committed Jan 8, 2024
1 parent e10f5dc commit 65cdf19
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ static void bsg_fallback_symbols(const uint64_t addr,
}

static bool bsg_check_invalid_libname(const std::string &filename) {
const auto length = filename.length();
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');
}

void bsg_unwinder_init() {
Expand Down

0 comments on commit 65cdf19

Please sign in to comment.