mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-30 21:37:53 -04:00
treewide: avoid unitialized spa_dict::flags
In multiple cases the `flags` member of `spa_dict` is left unitialized, so try to avoid that. For example in `fill_node_info_proplist()` it is accessed in `spa_dict_lookup_item()`. This also modifies `collect_props()` to not depend on a partially initialized `dict` parameter.
This commit is contained in:
parent
bcdc5356f2
commit
a4323c6814
4 changed files with 15 additions and 13 deletions
|
|
@ -180,8 +180,7 @@ static inline pa_proplist* pa_proplist_new_dict(const struct acp_dict *dict)
|
||||||
|
|
||||||
static inline void pa_proplist_as_dict(const pa_proplist *p, struct acp_dict *dict)
|
static inline void pa_proplist_as_dict(const pa_proplist *p, struct acp_dict *dict)
|
||||||
{
|
{
|
||||||
dict->n_items = pa_proplist_size(p);
|
*dict = ACP_DICT_INIT(p->array.data, pa_proplist_size(p));
|
||||||
dict->items = p->array.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,8 @@ uint32_t find_port_index(struct pw_manager_object *card, uint32_t direction, con
|
||||||
return SPA_ID_INVALID;
|
return SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spa_dict *collect_props(struct spa_pod *info, struct spa_dict *dict)
|
struct spa_dict *collect_props(struct spa_pod *info, struct spa_dict *dict,
|
||||||
|
struct spa_dict_item *items, size_t capacity)
|
||||||
{
|
{
|
||||||
struct spa_pod_parser prs;
|
struct spa_pod_parser prs;
|
||||||
struct spa_pod_frame f[1];
|
struct spa_pod_frame f[1];
|
||||||
|
|
@ -519,15 +520,18 @@ struct spa_dict *collect_props(struct spa_pod *info, struct spa_dict *dict)
|
||||||
spa_pod_parser_get_int(&prs, &n_items) < 0)
|
spa_pod_parser_get_int(&prs, &n_items) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (n_items < 0 || (size_t) n_items > capacity)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (n = 0; n < n_items; n++) {
|
for (n = 0; n < n_items; n++) {
|
||||||
if (spa_pod_parser_get(&prs,
|
if (spa_pod_parser_get(&prs,
|
||||||
SPA_POD_String(&dict->items[n].key),
|
SPA_POD_String(&items[n].key),
|
||||||
SPA_POD_String(&dict->items[n].value),
|
SPA_POD_String(&items[n].value),
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spa_pod_parser_pop(&prs, &f[0]);
|
spa_pod_parser_pop(&prs, &f[0]);
|
||||||
dict->n_items = n;
|
*dict = SPA_DICT_INIT(items, n);
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,8 @@ uint32_t collect_transport_codec_info(struct pw_manager_object *card,
|
||||||
|
|
||||||
/* ========================================================================== */
|
/* ========================================================================== */
|
||||||
|
|
||||||
struct spa_dict *collect_props(struct spa_pod *info, struct spa_dict *dict);
|
struct spa_dict *collect_props(struct spa_pod *info, struct spa_dict *dict,
|
||||||
|
struct spa_dict_item *items, size_t capacity);
|
||||||
uint32_t find_profile_index(struct pw_manager_object *card, const char *name);
|
uint32_t find_profile_index(struct pw_manager_object *card, const char *name);
|
||||||
uint32_t find_port_index(struct pw_manager_object *card, uint32_t direction, const char *port_name);
|
uint32_t find_port_index(struct pw_manager_object *card, uint32_t direction, const char *port_name);
|
||||||
struct pw_manager_object *find_peer_for_link(struct pw_manager *m,
|
struct pw_manager_object *find_peer_for_link(struct pw_manager *m,
|
||||||
|
|
|
||||||
|
|
@ -3307,7 +3307,7 @@ static int do_update_proplist(struct client *client, uint32_t command, uint32_t
|
||||||
static int do_remove_proplist(struct client *client, uint32_t command, uint32_t tag, struct message *m)
|
static int do_remove_proplist(struct client *client, uint32_t command, uint32_t tag, struct message *m)
|
||||||
{
|
{
|
||||||
uint32_t i, channel;
|
uint32_t i, channel;
|
||||||
struct spa_dict dict;
|
struct spa_dict dict = SPA_DICT_INIT(NULL, 0);
|
||||||
struct spa_dict_item *items;
|
struct spa_dict_item *items;
|
||||||
|
|
||||||
spa_autoptr(pw_properties) props = pw_properties_new(NULL, NULL);
|
spa_autoptr(pw_properties) props = pw_properties_new(NULL, NULL);
|
||||||
|
|
@ -3671,10 +3671,8 @@ static int fill_card_info(struct client *client, struct message *m,
|
||||||
pi = &port_info[n];
|
pi = &port_info[n];
|
||||||
|
|
||||||
if (pi->info && pi->n_props > 0 &&
|
if (pi->info && pi->n_props > 0 &&
|
||||||
(items = spa_alloca(pi->n_props, sizeof(*items), MAX_ALLOCA_SIZE)) != NULL) {
|
(items = spa_alloca(pi->n_props, sizeof(*items), MAX_ALLOCA_SIZE)) != NULL)
|
||||||
dict.items = items;
|
pdict = collect_props(pi->info, &dict, items, pi->n_props);
|
||||||
pdict = collect_props(pi->info, &dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
message_put(m,
|
message_put(m,
|
||||||
TAG_STRING, pi->name, /* port name */
|
TAG_STRING, pi->name, /* port name */
|
||||||
|
|
@ -4112,7 +4110,7 @@ static int fill_node_info_proplist(struct message *m, const struct spa_dict *nod
|
||||||
{
|
{
|
||||||
struct pw_client_info *client_info = client ? client->info : NULL;
|
struct pw_client_info *client_info = client ? client->info : NULL;
|
||||||
uint32_t n_items, n;
|
uint32_t n_items, n;
|
||||||
struct spa_dict dict, *client_props = NULL;
|
struct spa_dict dict = SPA_DICT_INIT(NULL, 0), *client_props = NULL;
|
||||||
const struct spa_dict_item *it;
|
const struct spa_dict_item *it;
|
||||||
struct spa_dict_item *items, *it2;
|
struct spa_dict_item *items, *it2;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue