Fix coverity defects: CID 161638

CID 161638: Resource leak (RESOURCE_LEAK)

Ensure the string array in print_zpool_script_help
is freed in cases when there is an error.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Closes #6111
This commit is contained in:
Giuseppe Di Natale 2017-05-09 11:34:19 -07:00 committed by Brian Behlendorf
parent e624cd1959
commit 3e2ecae01c

View File

@ -4131,8 +4131,11 @@ print_zpool_script_help(char *name, char *path)
rc = libzfs_run_process_get_stdout_nopath(path, argv, NULL, &lines,
&lines_cnt);
if (rc != 0 || lines == NULL || lines_cnt <= 0)
if (rc != 0 || lines == NULL || lines_cnt <= 0) {
if (lines != NULL)
libzfs_free_str_array(lines, lines_cnt);
return;
}
for (int i = 0; i < lines_cnt; i++)
if (!is_blank_str(lines[i]))