From ab6d16a8a5214ace81b9af346b9c065ec62fb04b Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 19 Oct 2015 10:59:09 +0200 Subject: [PATCH] dmeventd: check for malloc return --- daemons/dmeventd/dmeventd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index 56c504abe..80e6b14fb 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -1394,10 +1394,13 @@ static int _client_read(struct dm_event_fifos *fifos, bytes += ret > 0 ? ret : 0; if (header && (bytes == 2 * sizeof(uint32_t))) { msg->cmd = ntohl(header[0]); - msg->size = ntohl(header[1]); - buf = msg->data = dm_malloc(msg->size); - size = msg->size; + size = msg->size = ntohl(header[1]); bytes = 0; + if (!size) + break; /* No data -> error */ + buf = msg->data = dm_malloc(msg->size); + if (!buf) + break; /* No mem -> error */ header = 0; } } -- 2.43.5