mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Prevent dangling pointers
This commit is contained in:
parent
421277d730
commit
6935033db5
@ -331,6 +331,11 @@ void ZygiskModule::setOption(zygisk::Option opt) {
|
|||||||
|
|
||||||
void HookContext::run_modules_pre(const vector<int> &fds) {
|
void HookContext::run_modules_pre(const vector<int> &fds) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
|
// Since we directly use the pointer to elements in the vector, in order to prevent dangling
|
||||||
|
// pointers, the vector has to be pre-allocated to ensure reallocation does not occur
|
||||||
|
modules.reserve(fds.size());
|
||||||
|
|
||||||
for (int i = 0; i < fds.size(); ++i) {
|
for (int i = 0; i < fds.size(); ++i) {
|
||||||
snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fds[i]);
|
snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fds[i]);
|
||||||
if (void *h = dlopen(buf, RTLD_LAZY)) {
|
if (void *h = dlopen(buf, RTLD_LAZY)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user