mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
core: handle import errors better
Check for NULL when importing a buffer and log a message instead of trying to deref the NULL pointer and crash. Add some more logging to mem when importing a bad fd. See #3998
This commit is contained in:
parent
47a71325d6
commit
056d826c59
2 changed files with 5 additions and 2 deletions
|
|
@ -81,7 +81,10 @@ static void core_event_add_mem(void *data, uint32_t id, uint32_t type, int fd, u
|
||||||
pw_log_debug("%p: add mem %u type:%u fd:%d flags:%08x", this, id, type, fd, flags);
|
pw_log_debug("%p: add mem %u type:%u fd:%d flags:%08x", this, id, type, fd, flags);
|
||||||
|
|
||||||
m = pw_mempool_import(this->pool, flags, type, fd);
|
m = pw_mempool_import(this->pool, flags, type, fd);
|
||||||
if (m->id != id) {
|
if (m == NULL) {
|
||||||
|
pw_log_error("%p: can't import mem id:%u fd:%d: %m", this, id, fd);
|
||||||
|
pw_proxy_errorf(&this->proxy, -errno, "can't import mem id:%u: %m", id);
|
||||||
|
} else if (m->id != id) {
|
||||||
pw_log_error("%p: invalid mem id %u, fd:%d expected %u",
|
pw_log_error("%p: invalid mem id %u, fd:%d expected %u",
|
||||||
this, id, fd, m->id);
|
this, id, fd, m->id);
|
||||||
pw_proxy_errorf(&this->proxy, -EINVAL, "invalid mem id %u, expected %u", id, m->id);
|
pw_proxy_errorf(&this->proxy, -EINVAL, "invalid mem id %u, expected %u", id, m->id);
|
||||||
|
|
|
||||||
|
|
@ -648,7 +648,7 @@ struct pw_memblock * pw_mempool_import(struct pw_mempool *pool,
|
||||||
struct memblock *b;
|
struct memblock *b;
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pw_log_error("%p: cannot import invalid fd", pool);
|
pw_log_error("%p: cannot import invalid fd:%d", pool, fd);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue