Return value of a function 'elf_begin' is dereferenced at strip.c:1166 without checking for NULL, but it is usually checked for this function.
Found by RASU JSC. Signed-off-by: Maks Mishin <maks.mishi...@gmail.com> --- src/strip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/strip.c b/src/strip.c index 6436443d..ebab4866 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1153,7 +1153,9 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, { /* Also create an ELF descriptor for the debug file */ debugelf = elf_begin (debug_fd, ELF_C_WRITE, NULL); - if (unlikely (gelf_newehdr (debugelf, gelf_getclass (elf)) == 0)) + ELF_CHECK (debugelf != NULL, _("cannot create ELF descriptor: %s")); + + if (unlikely (gelf_newehdr (debugelf, gelf_getclass (elf)) == 0)) { error (0, 0, _("cannot create new ehdr for file '%s': %s"), debug_fname, elf_errmsg (-1)); -- 2.30.2