security: add missing NULL checks after message_alloc in reply

Both reply_new and reply_error passed the message_alloc result directly
to message_put without checking for NULL, which would cause a NULL
pointer dereference on allocation failure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-29 17:54:21 +02:00
parent 1b8962d7c2
commit 7c2d8f7251

View file

@ -17,6 +17,8 @@
struct message *reply_new(const struct client *client, uint32_t tag)
{
struct message *reply = message_alloc(client->impl, -1, 0);
if (reply == NULL)
return NULL;
pw_log_debug("client %p: new reply tag:%u", client, tag);
@ -55,6 +57,9 @@ int reply_error(struct client *client, uint32_t command, uint32_t tag, int res)
client, client->name, command, name, tag, error, spa_strerror(res));
reply = message_alloc(impl, -1, 0);
if (reply == NULL)
return -ENOMEM;
message_put(reply,
TAG_U32, COMMAND_ERROR,
TAG_U32, tag,