mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pulse-server: don't crash when alloc fails
This commit is contained in:
parent
0b69b92dc8
commit
09f423922d
1 changed files with 4 additions and 6 deletions
|
|
@ -302,22 +302,20 @@ static void message_free(struct impl *impl, struct message *msg, bool dequeue, b
|
||||||
|
|
||||||
static struct message *message_alloc(struct impl *impl, uint32_t channel, uint32_t size)
|
static struct message *message_alloc(struct impl *impl, uint32_t channel, uint32_t size)
|
||||||
{
|
{
|
||||||
struct message *msg = NULL;
|
struct message *msg;
|
||||||
|
|
||||||
if (!spa_list_is_empty(&impl->free_messages)) {
|
if (!spa_list_is_empty(&impl->free_messages)) {
|
||||||
msg = spa_list_first(&impl->free_messages, struct message, link);
|
msg = spa_list_first(&impl->free_messages, struct message, link);
|
||||||
spa_list_remove(&msg->link);
|
spa_list_remove(&msg->link);
|
||||||
pw_log_trace("using recycled message %p", msg);
|
pw_log_trace("using recycled message %p", msg);
|
||||||
}
|
} else {
|
||||||
if (msg == NULL) {
|
if ((msg = calloc(1, sizeof(struct message))) == NULL)
|
||||||
msg = calloc(1, sizeof(struct message));
|
return NULL;
|
||||||
pw_log_trace("new message %p", msg);
|
pw_log_trace("new message %p", msg);
|
||||||
msg->stat = &impl->stat;
|
msg->stat = &impl->stat;
|
||||||
msg->stat->n_allocated++;
|
msg->stat->n_allocated++;
|
||||||
msg->stat->n_accumulated++;
|
msg->stat->n_accumulated++;
|
||||||
}
|
}
|
||||||
if (msg == NULL)
|
|
||||||
return NULL;
|
|
||||||
ensure_size(msg, size);
|
ensure_size(msg, size);
|
||||||
spa_zero(msg->extra);
|
spa_zero(msg->extra);
|
||||||
msg->channel = channel;
|
msg->channel = channel;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue