Skip to contentSkip to conversation

runner/settings: Fix while loop

PATCH In review Peter Senna Tschudin 3 participants 3 messages Jun 26, 2025 – Jun 27, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 runner/settings: Fix while loop

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.

---
 runner/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
runner/settings.c +1 -1
index a7d5dbc97..4bd925934 100644
@@ -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) {
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Quoting Peter Senna Tschudin (2025-06-26 17:34:00-03:00)

Quoted 10 lines

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.

And... :facepalm:

Thanks for catching this!

--
Gustavo Sousa

Quoted 20 lines

---
runner/settings.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
runner/settings.c +1 -1
index a7d5dbc97..4bd925934 100644
@@ -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) {
Signature · 1 line
2.43.0