rpm/backport-Fix-elf-leak-in-getElfColor.patch

29 lines
657 B
Diff

From 01196e00beefc2ba6f7f0787350c5dd76891829a Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Fri, 25 Nov 2022 17:11:22 +0800
Subject: [PATCH 3/5] Fix elf leak in getElfColor
The "elf" is leaked in getElfColor when gelf_getehdr return fail.
---
build/rpmfc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index d35c148b9..06205469c 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1145,8 +1145,9 @@ static uint32_t getElfColor(const char *fn)
color = RPMFC_ELF32;
break;
}
- elf_end(elf);
}
+ if (elf)
+ elf_end(elf);
close(fd);
}
#endif
--
2.27.0