summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-parser.c9
-rwxr-xr-xtests/bugs/cli/bug-1169302.t3
2 files changed, 10 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 16b0cc81cd6..5472b3e8f38 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3607,7 +3607,9 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount,
goto out;
}
}
- if ((strstr (option_str, "nfs")) && strstr (option_str, "quotad")) {
+ if (option_str &&
+ (strstr (option_str, "nfs")) &&
+ strstr (option_str, "quotad")) {
ret = -1;
goto out;
}
@@ -3619,7 +3621,10 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount,
goto out;
}
- ret = dict_set_dynstr (dict, "options", option_str);
+ /* dynamic string in dict is freed up when dict is freed up, and hence
+ if option_str is NULL pass in an duplicate empty string to the same */
+ ret = dict_set_dynstr (dict, "options",
+ (option_str ? option_str : gf_strdup("")));
if (ret)
goto out;
option_str = NULL;
diff --git a/tests/bugs/cli/bug-1169302.t b/tests/bugs/cli/bug-1169302.t
index 0bdaf56307e..19660e033a8 100755
--- a/tests/bugs/cli/bug-1169302.t
+++ b/tests/bugs/cli/bug-1169302.t
@@ -20,6 +20,9 @@ TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 $H3:$B3/$V0
TEST $CLI_1 volume start $V0
# test CLI parameter acceptance
+TEST $CLI_1 volume statedump $V0
+TEST $CLI_2 volume statedump $V0
+TEST $CLI_3 volume statedump $V0
TEST ! $CLI_1 volume statedump $V0 client $H2:0
TEST ! $CLI_2 volume statedump $V0 client $H2:-1
TEST $CLI_3 volume statedump $V0 client $H2:765