Check overflows in c-tor instead of doing it in d-tor

Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: Id3b17a79732155b4e469c43c764afef1dfc59057
This commit is contained in:
Dimitry Ivanov 2017-02-01 12:55:11 -08:00
parent 3c838bbb4a
commit 68e6c03081

View file

@ -462,13 +462,13 @@ ProtectedDataGuard::ProtectedDataGuard() {
if (ref_count_++ == 0) {
protect_data(PROT_READ | PROT_WRITE);
}
}
ProtectedDataGuard::~ProtectedDataGuard() {
if (ref_count_ == 0) { // overflow
__libc_fatal("Too many nested calls to dlopen()");
}
}
ProtectedDataGuard::~ProtectedDataGuard() {
if (--ref_count_ == 0) {
protect_data(PROT_READ);
}