mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
libzfs: run_process: don't leak fd on reopen failure
Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12082
This commit is contained in:
parent
7c20ceebdd
commit
5da6353987
@ -849,8 +849,10 @@ libzfs_read_stdout_from_fd(int fd, char **lines[])
|
||||
char **tmp_lines = NULL, **tmp;
|
||||
|
||||
fp = fdopen(fd, "r");
|
||||
if (fp == NULL)
|
||||
if (fp == NULL) {
|
||||
close(fd);
|
||||
return (0);
|
||||
}
|
||||
while (getline(&line, &len, fp) != -1) {
|
||||
tmp = realloc(tmp_lines, sizeof (*tmp_lines) * (lines_cnt + 1));
|
||||
if (tmp == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user