From 1c6ce1778b77543fe08d2641c08a07869cb1677b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 28 Jan 2020 12:52:01 +0100 Subject: [PATCH] pw-cli: handle NULL when iterating globals It is possible that the global map contains holes and then the pw_map item has NULL data. --- src/tools/pw-cli.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index f5d6c2578..c95976599 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -1720,9 +1720,11 @@ children_of(struct remote_data *rd, uint32_t parent_id, } i = 0; pw_array_for_each(item, &rd->globals.items) { - if (pw_map_item_is_free(item)) + if (pw_map_item_is_free(item) || item->data == NULL) continue; + global = item->data; + if (strcmp(global->type, child_type)) continue; @@ -2600,8 +2602,9 @@ static bool do_dump(struct data *data, const char *cmd, char *args, char **error } pw_array_for_each(item, &rd->globals.items) { - if (pw_map_item_is_free(item)) + if (pw_map_item_is_free(item) || item->data == NULL) continue; + global = item->data; /* unknown type, ignore completely */