[PATCH 15/34] lscpu: fix memory leak [clang-analyzer]

Sami Kerola
2013-07-07T19:55:41Z

sys-utils/lscpu-dmi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c
index 21e024b..8f02779 100644
--- a/sys-utils/lscpu-dmi.c
+++ b/sys-utils/lscpu-dmi.c
@@ -130,8 +130,10 @@ static int hypervisor_from_dmi_table(uint32_t base, uint16_t len,
* is invalid, but we cannot reliably locate the next entry.
* Better stop at this point.
*/
- if (h.length < 4)
+ if (h.length < 4) {
+ free(data);
return HYPER_NONE;
+ }

/* look for the next handle */
next = data + h.length;
--
1.8.3.2