[igt-dev] [PATCH i-g-t] runner: Don't free uninitialized pointers in add_env_var

Ryszard Knop ryszard.knop at intel.com
Thu Sep 1 09:04:31 UTC 2022


If we goto error before assigning env_kv, it's left uninitialized, which
we later attempt to free(). Initialize both variables to NULL.

Signed-off-by: Ryszard Knop <ryszard.knop at intel.com>
---
 runner/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runner/settings.c b/runner/settings.c
index 23aa8296..e8e1f50e 100644
--- a/runner/settings.c
+++ b/runner/settings.c
@@ -440,7 +440,7 @@ static char *string_trim_and_duplicate(const char *string) {
  * an empty variable for the runner process, then providing just the "KEY".
  */
 static bool add_env_var(struct igt_list_head *env_vars, const char *key_value) {
-	char *env_kv, *value_str;
+	char *env_kv = NULL, *value_str = NULL;
 	struct environment_variable *var = NULL;
 
 	if (env_vars == NULL || key_value == NULL || strlen(key_value) == 0)
-- 
2.37.3



More information about the igt-dev mailing list