From df1e2983e95d1199e92be175167169c603cdcf08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BF=97=E5=BA=B7?= Date: Thu, 8 May 2025 10:24:25 +0800 Subject: [PATCH] fix bug of null pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王志康 --- src/ar.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ar.c b/src/ar.c index 3bcb18fe..1a76cbc6 100644 --- a/src/ar.c +++ b/src/ar.c @@ -494,6 +494,8 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + goto next; if (strcmp (arhdr->ar_name, "/") == 0) { @@ -939,6 +941,8 @@ do_oper_delete (const char *arfname, char **argv, int argc, while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + goto next; /* Ignore the symbol table and the long file name table here. */ if (strcmp (arhdr->ar_name, "/") == 0 @@ -1148,6 +1152,8 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + goto next; /* Ignore the symbol table and the long file name table here. */ if (strcmp (arhdr->ar_name, "/") == 0 -- Gitee