Skip to content

Commit

Permalink
Fix #260, Restore the origin value
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfufeng committed Nov 9, 2023
1 parent a5430e2 commit 7b89411
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion koom-native-leak/src/main/jni/src/memory_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ MemoryAnalyzer::CollectUnreachableMem() {
return std::move(unreachable_mem);
}

int origin_dumpable = prctl(PR_GET_DUMPABLE);

// libmemunreachable NOT work in release apk because it using ptrace
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
ALOGE("Set process dumpable Fail");
Expand All @@ -85,7 +87,7 @@ MemoryAnalyzer::CollectUnreachableMem() {
std::string unreachable_memory = get_unreachable_fn_(false, 1024);

// Unset "dumpable" for security
prctl(PR_SET_DUMPABLE, 0, 0, 0, 0);
prctl(PR_SET_DUMPABLE, origin_dumpable, 0, 0, 0);

std::regex filter_regex("[0-9]+ bytes unreachable at [A-Za-z0-9]+");
std::sregex_iterator unreachable_begin(
Expand Down

0 comments on commit 7b89411

Please sign in to comment.