summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu Fengqi <lufq.fnst@cn.fujitsu.com>2017-10-26 16:32:51 +0800
committerDavid Sterba <dsterba@suse.com>2017-11-14 15:59:00 +0100
commitc1e92291ee0f4248e5cd2f12dd2d79e16ad9721b (patch)
treedc634eeb5e4b1ea1adeb42d1b1516d2bde0fb6c7
parentb84aa6033c340118e5ecc18acecd6b7492569fa7 (diff)
btrfs-progs: qgroup: fix qgroup show sort by multi items
We should not free the string until we don't call strtok any longer. If the string is freed in advance, in fact, the second and subsequent sort items will be ignored. Fixes: 9fcdf8f8945b ("btrfs-progs: don't write to optarg in btrfs_qgroup_parse_sort_string") Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--qgroup.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/qgroup.c b/qgroup.c
index fffdbb12..7e8ef079 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -1222,7 +1222,8 @@ int btrfs_qgroup_parse_sort_string(const char *opt_arg,
if (!opt_tmp)
return -ENOMEM;
- while ((p = strtok(opt_tmp, ",")) != NULL) {
+ p = strtok(opt_tmp, ",");
+ while (p) {
flag = 0;
ptr_argv = all_sort_items;
@@ -1262,8 +1263,7 @@ int btrfs_qgroup_parse_sort_string(const char *opt_arg,
}
btrfs_qgroup_setup_comparer(comps, what_to_sort, order);
}
- free(opt_tmp);
- opt_tmp = NULL;
+ p = strtok(NULL, ",");
}
out: