bluez5: handle some allocation failures

This commit is contained in:
Wim Taymans 2026-05-04 14:27:34 +02:00
parent 6539c2bf8c
commit 057ae16504
2 changed files with 12 additions and 1 deletions

View file

@ -3505,6 +3505,10 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
rfcomm->profile = profile; rfcomm->profile = profile;
rfcomm->device = d; rfcomm->device = d;
rfcomm->path = strdup(path); rfcomm->path = strdup(path);
if (rfcomm->path == NULL) {
free(rfcomm);
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
rfcomm->source.func = rfcomm_event; rfcomm->source.func = rfcomm_event;
rfcomm->source.data = rfcomm; rfcomm->source.data = rfcomm;
rfcomm->source.fd = spa_steal_fd(fd); rfcomm->source.fd = spa_steal_fd(fd);

View file

@ -3497,8 +3497,15 @@ filter_bluez_device_setting(struct impl *this, const struct spa_dict *dict)
{ {
const struct spa_dict_item *it = &dict->items[i]; const struct spa_dict_item *it = &dict->items[i];
if (it->key != NULL && strncmp(it->key, "bluez", 5) == 0 && it->value != NULL) { if (it->key != NULL && strncmp(it->key, "bluez", 5) == 0 && it->value != NULL) {
char *key = strdup(it->key);
char *value = strdup(it->value);
if (key == NULL || value == NULL) {
free(key);
free(value);
continue;
}
this->setting_items[n_items++] = this->setting_items[n_items++] =
SPA_DICT_ITEM_INIT(strdup(it->key), strdup(it->value)); SPA_DICT_ITEM_INIT(key, value);
} }
} }
this->setting_dict = SPA_DICT_INIT(this->setting_items, n_items); this->setting_dict = SPA_DICT_INIT(this->setting_items, n_items);