mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
btrfs_balance_status: delay allocation of 'ret'
Allocate 'ret' as late as possible, so there is no risk that early
returns will leak it.
(cherry picked from commit 31ee088812)
This commit is contained in:
committed by
Richard W.M. Jones
parent
961c37995e
commit
8d5f54b45c
@@ -1683,12 +1683,6 @@ do_btrfs_balance_status (const char *path)
|
||||
|
||||
nlines = guestfs_int_count_strings (lines);
|
||||
|
||||
ret = calloc (1, sizeof *ret);
|
||||
if (ret == NULL) {
|
||||
reply_with_perror ("calloc");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Output of `btrfs balance status' is like:
|
||||
*
|
||||
* running:
|
||||
@@ -1711,6 +1705,12 @@ do_btrfs_balance_status (const char *path)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = calloc (1, sizeof *ret);
|
||||
if (ret == NULL) {
|
||||
reply_with_perror ("calloc");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strstr (lines[0], "No balance found on")) {
|
||||
ret->btrfsbalance_status = strdup ("none");
|
||||
if (ret->btrfsbalance_status == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user