From: Guus Sliepen Date: Sat, 11 Apr 2020 22:38:54 +0000 (+0200) Subject: Handle the case where we reduce the buffer size below the amount currently used. X-Git-Url: http://git.meshlink.io/?p=utcp;a=commitdiff_plain;h=9fe3be0ad54dd1e0c8766957ea402d555d947839 Handle the case where we reduce the buffer size below the amount currently used. --- diff --git a/utcp.c b/utcp.c index 75d4f83..6279d92 100644 --- a/utcp.c +++ b/utcp.c @@ -401,7 +401,7 @@ static void buffer_exit(struct buffer *buf) { } static uint32_t buffer_free(const struct buffer *buf) { - return buf->maxsize - buf->used; + return buf->maxsize > buf->used ? buf->maxsize - buf->used : 0; } // Connections are stored in a sorted list.