From 3704db8f8496ffd967ef8d8840eef2c04b7f4b06 Mon Sep 17 00:00:00 2001
From: Mikhail Sokolovskiy <sokolmish@gmail.com>
Date: Fri, 1 Jul 2022 17:34:24 +0300
Subject: rsockets: Fix allocation size There is memory allocation for (nfds +
 1) elements, but actually less space is allocated (1 byte for new element
 instead of sizeof(pollfd)). This is caused by operators precedence mistake.

Signed-off-by: Mikhail Sokolovskiy <sokolmish@gmail.com>
---
 librdmacm/rsocket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c
index 8c81096..e26a053 100644
--- a/librdmacm/rsocket.c
+++ b/librdmacm/rsocket.c
@@ -3173,7 +3173,7 @@ static struct pollfd *rs_fds_alloc(nfds_t nfds)
 		else if (rs_pollinit())
 			return NULL;
 
-		rfds = malloc(sizeof(*rfds) * nfds + 1);
+		rfds = malloc(sizeof(*rfds) * (nfds + 1));
 		rnfds = rfds ? nfds + 1 : 0;
 	}
 
-- 
2.34.1

