Skip to content

Commit a437584

Browse files
committed
Safer sections iteration
1 parent 4a678c7 commit a437584

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

elf/elf.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,14 @@ elf::elf(const std::shared_ptr<loader> &l)
103103
// Load sections
104104
const void *sec_data = l->load(m->hdr.shoff,
105105
m->hdr.shentsize * m->hdr.shnum);
106+
if (NULL == sec_data) {
107+
return;
108+
}
106109
for (unsigned i = 0; i < m->hdr.shnum; i++) {
107110
const void *sec = ((const char*)sec_data) + i * m->hdr.shentsize;
111+
if (NULL == sec) {
112+
continue;
113+
}
108114
// XXX Circular reference. Maybe this should be
109115
// constructed on the fly? Canonicalizing the header
110116
// isn't super-cheap.

0 commit comments

Comments
 (0)