summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGiuseppe Di Natale <[email protected]>2017-05-09 11:34:19 -0700
committerBrian Behlendorf <[email protected]>2017-05-09 11:34:19 -0700
commit3e2ecae01c6de6f885eca2ea78f00db2d21065ef (patch)
treec444d643ad44e282bd3d8bff57cdab8f4d0a1cc1 /cmd
parente624cd1959904735eda81f1a9a45d99848bb3503 (diff)
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 <[email protected]> Signed-off-by: Giuseppe Di Natale <[email protected]> Closes #6111
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zpool/zpool_main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index edcfe2db7..6a54c92c3 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -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]))