[igt-dev] [PATCH i-g-t v2] runner: Fix a memory leak in stderr_contains_warnings

Petri Latvala petri.latvala at intel.com
Mon Nov 14 14:10:46 UTC 2022


The matches object's internals weren't released.

v2: Don't leak in the other branch either. (Kamil)

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Arkadiusz Hiler <arek at hiler.eu>
Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
 runner/resultgen.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/runner/resultgen.c b/runner/resultgen.c
index 3d753828..05c4234e 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -1902,17 +1902,22 @@ static bool stderr_contains_warnings(const char *beg, const char *end)
 	};
 	struct matches matches;
 	size_t i = 0;
+	bool found = false;
 
 	matches = find_matches(beg, end, needles);
 
 	while (i < matches.size) {
-		if (matches.items[i].where != beg)
-			return true;
+		if (matches.items[i].where != beg) {
+			found = true;
+			break;
+		}
 		beg = next_line(beg, end);
 		i++;
 	}
 
-	return false;
+	free_matches(&matches);
+
+	return found;
 }
 
 static bool json_field_has_data(struct json_object *obj, const char *key)
-- 
2.30.2



More information about the igt-dev mailing list