]> granicus.if.org Git - sudo/commitdiff
Fix memory leak on error if sudo_new_key_val() fails.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 7 May 2016 10:57:11 +0000 (04:57 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 7 May 2016 10:57:11 +0000 (04:57 -0600)
Coverity CID 104103.

src/sudo.c

index c4c85c4993b841c49066b2af039c29fcdb14ae53..2217d6ae22d838eda5bbc83f3f27700b7c6496fc 100644 (file)
@@ -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)