mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 14:03:17 +00:00
src/useradd.c: set_defaults(): Do not free(3) the result of asprintf(3) if it failed
See asprintf(3):
RETURN VALUE
When successful, these functions return the number of bytes
printed, just like sprintf(3). If memory allocation wasn’t possi‐
ble, or some other error occurs, these functions will return -1,
and the contents of strp are undefined.
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
37ae8827a0
commit
701fe4cf1a
@ -558,7 +558,7 @@ static int set_defaults (void)
|
||||
fprintf(stderr,
|
||||
_("%s: cannot create new defaults file: %s\n"),
|
||||
Prog, strerror(errno));
|
||||
goto err_free_def;
|
||||
goto err_free_new;
|
||||
}
|
||||
}
|
||||
|
||||
@ -749,6 +749,7 @@ static int set_defaults (void)
|
||||
err_free_def:
|
||||
if (prefix[0])
|
||||
free(default_file);
|
||||
err_free_new:
|
||||
free(new_file);
|
||||
|
||||
return ret;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user