[PATCH i-g-t] runner/settings: Fix while loop

Gustavo Sousa gustavo.sousa at intel.com
Thu Jun 26 20:44:48 UTC 2025


Quoting Peter Senna Tschudin (2025-06-26 17:34:00-03:00)
>Passing a large argument to the --hook option caused igt_runner to
>crash.  Valgrind identified an issue in read_hook_strs_from_file(),
>which this patch addresses.
>
>A typo in parenthesis placement caused the assignment of 0 or 1 to
>line_length, not the actual line length, because != -1 was evaluated
>before assignment.
>
>Cc: Gustavo Sousa <gustavo.sousa at intel.com>
>Signed-off-by: Peter Senna Tschudin <peter.senna at linux.intel.com>

Reviewed-by: Gustavo Sousa <gustavo.sousa at intel.com>

And... :facepalm:

Thanks for catching this!

--
Gustavo Sousa

>---
> runner/settings.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/runner/settings.c b/runner/settings.c
>index a7d5dbc97..4bd925934 100644
>--- a/runner/settings.c
>+++ b/runner/settings.c
>@@ -1458,7 +1458,7 @@ static bool read_hook_strs_from_file(struct igt_vec *hook_strs, FILE *f)
> 
>         buf = malloc(buf_capacity);
> 
>-        while ((line_length = getline(&line, &line_size, f) != -1)) {
>+        while ((line_length = getline(&line, &line_size, f)) != -1) {
>                 char *s = line;
> 
>                 if (buf_len == 0) {
>-- 
>2.43.0
>


More information about the igt-dev mailing list