Fix an UAF UB (#1607)

This commit is contained in:
LoveSy 2022-02-02 17:06:03 +08:00 committed by GitHub
parent 3c03d4d160
commit ad2ff45789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -248,9 +248,8 @@ bool ElfImg::findModuleBase() {
}
}
}
if (buff) free(buff);
if (!found) {
if (buff) free(buff);
LOGE("failed to read load address for %s", elf.data());
fclose(maps);
return false;
@ -260,6 +259,8 @@ bool ElfImg::findModuleBase() {
LOGE("failed to read load address for %s", elf.data());
}
if (buff) free(buff);
fclose(maps);
LOGD("get module base %s: %lx", elf.data(), load_addr);