From 83de17ca9b9718c95461b2d6794994a27964037f Mon Sep 17 00:00:00 2001 From: Dmytro Shytyi Date: Wed, 29 Jan 2025 14:52:20 +0100 Subject: [PATCH] lib: call to 'calloc' has an allocation size of 0 bytes w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum); Signed-off-by: Dmytro Shytyi --- lib/elf_py.c | 4 ++-- 1 file 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; -- 2.39.5