adamwill / rpms / openscap

Forked from rpms/openscap 3 years ago
Clone

Blame SOURCES/openscap-1.3.5-plug-memory-leak-PR_1616.patch

8143af
From d5518f3f4c32ac19fcf3427602d5b2978b7ef1b4 Mon Sep 17 00:00:00 2001
8143af
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
8143af
Date: Mon, 5 Oct 2020 16:02:29 +0200
8143af
Subject: [PATCH] Plug a memory leak
8143af
8143af
Addressing:
8143af
8143af
8 bytes in 1 blocks are indirectly lost in loss record 7 of 235
8143af
   at 0x483A809: malloc (vg_replace_malloc.c:307)
8143af
   by 0x48F15CA: oval_collection_new (oval_collection.c:64)
8143af
   by 0x48F4FCC: oval_result_criteria_node_new (oval_resultCriteriaNode.c:106)
8143af
   by 0x48F5580: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:249)
8143af
   by 0x48F6B51: make_result_definition_from_oval_definition (oval_resultDefinition.c:130)
8143af
   by 0x48F7F41: oval_result_system_get_new_definition_with_check (oval_resultSystem.c:217)
8143af
   by 0x48F5686: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:279)
8143af
   by 0x48F55BD: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:260)
8143af
   by 0x48F6B51: make_result_definition_from_oval_definition (oval_resultDefinition.c:130)
8143af
   by 0x48F8794: oval_result_system_prepare_definition (oval_resultSystem.c:395)
8143af
   by 0x48F86A6: oval_result_system_eval_definition (oval_resultSystem.c:369)
8143af
   by 0x48C23FD: oval_agent_eval_definition (oval_agent.c:181)
8143af
8143af
8 bytes in 1 blocks are definitely lost in loss record 8 of 235
8143af
   at 0x483A809: malloc (vg_replace_malloc.c:307)
8143af
   by 0x48F1799: oval_collection_iterator (oval_collection.c:120)
8143af
   by 0x48CCE4C: oval_criteria_node_get_subnodes (oval_criteriaNode.c:161)
8143af
   by 0x48F5590: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:255)
8143af
   by 0x48F6B51: make_result_definition_from_oval_definition (oval_resultDefinition.c:130)
8143af
   by 0x48F7F41: oval_result_system_get_new_definition_with_check (oval_resultSystem.c:217)
8143af
   by 0x48F5686: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:279)
8143af
   by 0x48F55BD: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:260)
8143af
   by 0x48F6B51: make_result_definition_from_oval_definition (oval_resultDefinition.c:130)
8143af
   by 0x48F8794: oval_result_system_prepare_definition (oval_resultSystem.c:395)
8143af
   by 0x48F86A6: oval_result_system_eval_definition (oval_resultSystem.c:369)
8143af
   by 0x48C23FD: oval_agent_eval_definition (oval_agent.c:181)
8143af
8143af
48 (40 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 125 of 235
8143af
   at 0x483A809: malloc (vg_replace_malloc.c:307)
8143af
   by 0x48F4F50: oval_result_criteria_node_new (oval_resultCriteriaNode.c:98)
8143af
   by 0x48F5580: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:249)
8143af
   by 0x48F6B51: make_result_definition_from_oval_definition (oval_resultDefinition.c:130)
8143af
   by 0x48F7F41: oval_result_system_get_new_definition_with_check (oval_resultSystem.c:217)
8143af
   by 0x48F5686: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:279)
8143af
   by 0x48F55BD: make_result_criteria_node_from_oval_criteria_node (oval_resultCriteriaNode.c:260)
8143af
   by 0x48F6B51: make_result_definition_from_oval_definition (oval_resultDefinition.c:130)
8143af
   by 0x48F8794: oval_result_system_prepare_definition (oval_resultSystem.c:395)
8143af
   by 0x48F86A6: oval_result_system_eval_definition (oval_resultSystem.c:369)
8143af
   by 0x48C23FD: oval_agent_eval_definition (oval_agent.c:181)
8143af
   by 0x48C2671: oval_agent_eval_system (oval_agent.c:286)
8143af
8143af
This leak has been created by #1610.
8143af
---
8143af
 src/OVAL/results/oval_resultCriteriaNode.c | 5 ++++-
8143af
 1 file changed, 4 insertions(+), 1 deletion(-)
8143af
8143af
diff --git a/src/OVAL/results/oval_resultCriteriaNode.c b/src/OVAL/results/oval_resultCriteriaNode.c
8143af
index 807283206..f6e980861 100644
8143af
--- a/src/OVAL/results/oval_resultCriteriaNode.c
8143af
+++ b/src/OVAL/results/oval_resultCriteriaNode.c
8143af
@@ -258,8 +258,11 @@ struct oval_result_criteria_node *make_result_criteria_node_from_oval_criteria_n
8143af
 					    = oval_criteria_node_iterator_next(oval_subnodes);
8143af
 					struct oval_result_criteria_node *rslt_subnode
8143af
 						= make_result_criteria_node_from_oval_criteria_node(sys, oval_subnode, visited_definitions, variable_instance);
8143af
-					if (rslt_subnode == NULL)
8143af
+					if (rslt_subnode == NULL) {
8143af
+						oval_criteria_node_iterator_free(oval_subnodes);
8143af
+						oval_result_criteria_node_free(rslt_node);
8143af
 						return NULL;
8143af
+					}
8143af
 					oval_result_criteria_node_add_subnode(rslt_node, rslt_subnode);
8143af
 				}
8143af
 				oval_criteria_node_iterator_free(oval_subnodes);