From 5bdda673ccfa36fb10ea115366cd0bc1dfc126b0 Mon Sep 17 00:00:00 2001
From: Sergey Bronnikov <sergeyb@tarantool.org>
Date: Mon, 7 Oct 2024 11:55:23 +0300
Subject: [PATCH] httpc: replace ibuf_alloc with xibuf_alloc

There is no check for NULL for a value returned by `ibuf_alloc`,
the NULL will be passed to `memcpy()` if the aforementioned
function will return a NULL. The patch fixes that by replacing
`ibuf_alloc` with macros `xibuf_alloc` that never return NULL.

Found by Svace.

NO_CHANGELOG=codehealth
NO_DOC=codehealth
NO_TEST=codehealth

(cherry picked from commit b4ee146fde6e418aed590ac6054cff75c2a59626)
---
 src/httpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/httpc.c b/src/httpc.c
index 30327afd4f..dd2af53e57 100644
--- a/src/httpc.c
+++ b/src/httpc.c
@@ -578,7 +578,7 @@ httpc_request_io_read(struct httpc_request *req, char *buf, size_t len,
 
 		if (recv_len > remain) {
 			const size_t tocopy = recv_len - remain;
-			char *ptr = ibuf_alloc(&req->io_recv, tocopy);
+			char *ptr = xibuf_alloc(&req->io_recv, tocopy);
 			memcpy(ptr, recv + remain, tocopy);
 		}
 
@@ -626,7 +626,7 @@ httpc_request_io_write(struct httpc_request *req, const char *ptr, size_t len,
 
 	if (len > 0) {
 		ibuf_reset(&req->send);
-		char *buf = ibuf_alloc(&req->send, len);
+		char *buf = xibuf_alloc(&req->send, len);
 		memcpy(buf, ptr, len);
 	} else {
 		req->io_send_closed = true;
-- 
GitLab