security: add missing NULL check after strdup in pw-dump

Memory Safety: Medium

In the registry event handler, strdup(type) was not checked for
failure. A NULL o->type would cause NULL pointer dereferences in
subsequent code that uses the type string for comparison and logging.

Fix by checking the strdup() return value and cleaning up on failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-28 13:20:33 +02:00
parent 43931caccb
commit ec04c4bf9a

View file

@ -1215,6 +1215,11 @@ static void registry_event_global(void *data, uint32_t id,
o->id = id;
o->permissions = permissions;
o->type = strdup(type);
if (o->type == NULL) {
pw_log_error("can't alloc type for %u %s/%d: %m", id, type, version);
free(o);
return;
}
o->version = version;
o->props = props ? pw_properties_new_dict(props) : NULL;
spa_list_init(&o->param_list);