pulse-server: handle message errors

This commit is contained in:
Wim Taymans 2020-10-21 12:00:25 +02:00
parent bb8bd3d76d
commit bc1192c8dd
2 changed files with 21 additions and 0 deletions

View file

@ -272,6 +272,17 @@ static int send_message(struct client *client, struct message *m)
struct impl *impl = client->impl;
int res;
if (m == NULL)
return -EINVAL;
if (m->length == 0) {
res = 0;
goto error;
} else if (m->length > m->allocated) {
res = -ENOMEM;
goto error;
}
m->offset = 0;
spa_list_append(&client->out_messages, &m->link);
res = flush_messages(client);
@ -282,6 +293,10 @@ static int send_message(struct client *client, struct message *m)
res = 0;
}
return res;
error:
if (m)
message_free(client, m, false, false);
return res;
}
static struct message *reply_new(struct client *client, uint32_t tag)