security: add missing NULL check after strdup in reserve

Memory Safety: Medium

rd_device_new() did not check the return value of strdup() when
duplicating application_name. On allocation failure, a NULL pointer
would be stored and later passed to D-Bus functions, causing a
crash. Add a NULL check that jumps to the existing error_free
cleanup path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-29 11:35:31 +02:00
parent 4de0f83aca
commit c3c1216633

View file

@ -357,6 +357,10 @@ rd_device_new(DBusConnection *connection, const char *device_name, const char *a
d->data = data;
d->application_name = strdup(application_name);
if (d->application_name == NULL) {
res = -ENOMEM;
goto error_free;
}
d->object_path = spa_aprintf(OBJECT_PREFIX "%s", device_name);
if (d->object_path == NULL) {