From 9d1476a760efb95486aff866045371f17cd6661d Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 30 Dec 2023 21:41:48 +0000 Subject: [PATCH] Slight memcpy paranoia. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4713 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/http.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index a8d7bf8a..803ef27e 100644 --- a/src/http.c +++ b/src/http.c @@ -230,9 +230,12 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d { if (connection->is_websocket) { - connection->body = tf_realloc(connection->body, connection->body_length + size); - memcpy((char*)connection->body + connection->body_length, data, size); - connection->body_length += size; + if (size) + { + connection->body = tf_realloc(connection->body, connection->body_length + size); + memcpy((char*)connection->body + connection->body_length, data, size); + connection->body_length += size; + } while (connection->body_length >= 2) {