public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2] runner: Fix a memory leak in stderr_contains_warnings
Date: Mon, 14 Nov 2022 16:10:46 +0200	[thread overview]
Message-ID: <20221114141046.2466004-1-petri.latvala@intel.com> (raw)
In-Reply-To: <20221111080529.2427645-1-petri.latvala@intel.com>

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@intel.com>
Cc: Arkadiusz Hiler <arek@hiler.eu>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@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

  parent reply	other threads:[~2022-11-14 14:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11  8:05 [igt-dev] [PATCH i-g-t] runner: Fix a memory leak in stderr_contains_warnings Petri Latvala
2022-11-11  8:58 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2022-11-12  2:43 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-11-14 12:52 ` [igt-dev] [PATCH i-g-t] " Kamil Konieczny
2022-11-14 14:03 ` Kamil Konieczny
2022-11-14 14:06   ` Petri Latvala
2022-11-14 14:10 ` Petri Latvala [this message]
2022-11-14 15:18 ` [igt-dev] ✓ Fi.CI.BAT: success for runner: Fix a memory leak in stderr_contains_warnings (rev2) Patchwork
2022-11-14 20:50 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221114141046.2466004-1-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox