]> git.meshlink.io Git - utcp/commitdiff
Handle the case where we reduce the buffer size below the amount currently used.
authorGuus Sliepen <guus@sliepen.org>
Sat, 11 Apr 2020 22:38:54 +0000 (00:38 +0200)
committerGuus Sliepen <guus@sliepen.org>
Sat, 11 Apr 2020 22:38:54 +0000 (00:38 +0200)
utcp.c

diff --git a/utcp.c b/utcp.c
index 75d4f83417a3be30bccc6346757abef8f7643585..6279d925a781814eeb06710c406fa47063c2f052 100644 (file)
--- 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.