]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: call to 'calloc' has an allocation size of 0 bytes
authorDmytro Shytyi <dmytro.shytyi@6wind.com>
Wed, 29 Jan 2025 13:52:20 +0000 (14:52 +0100)
committerDmytro Shytyi <dmytro.shytyi@6wind.com>
Tue, 11 Mar 2025 10:16:01 +0000 (11:16 +0100)
w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
lib/elf_py.c

index 6c63d1f892023153401ccdcc5a285a558f9ffed2..14012a2173047a6b94a5f1e6ae9ab5df5b7e90f9 100644 (file)
@@ -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;