From 0f359e038c7ea34525c4673dfb07f803d4b264be Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 7 May 2016 04:57:11 -0600 Subject: [PATCH] Fix memory leak on error if sudo_new_key_val() fails. Coverity CID 104103. --- src/sudo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sudo.c b/src/sudo.c index c4c85c499..2217d6ae2 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -576,10 +576,10 @@ get_user_info(struct user_details *ud) cp = sudo_gethostname(); user_info[++i] = sudo_new_key_val("host", cp ? cp : "localhost"); + free(cp); if (user_info[i] == NULL) goto bad; ud->host = user_info[i] + sizeof("host=") - 1; - free(cp); sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols); if (asprintf(&user_info[++i], "lines=%d", ud->ts_lines) == -1) -- 2.40.0