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

Petri Latvala petri.latvala at intel.com
Thu Sep 1 09:20:10 UTC 2022


On Thu, Sep 01, 2022 at 11:04:31AM +0200, Ryszard Knop wrote:
> 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>

Reviewed-by: Petri Latvala <petri.latvala 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