summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/elf_py.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/elf_py.c b/lib/elf_py.c
index 6c63d1f892..14012a2173 100644
--- a/lib/elf_py.c
+++ b/lib/elf_py.c
@@ -1306,8 +1306,8 @@ static PyObject *elffile_load(PyTypeObject *type, PyObject *args,
}
}
#endif
-
- w->sects = calloc(w->ehdr->e_shnum, sizeof(PyObject *));
+ if (w->ehdr->e_shnum > 0)
+ w->sects = calloc(w->ehdr->e_shnum, sizeof(PyObject *));
w->n_sect = w->ehdr->e_shnum;
return (PyObject *)w;