From 288f36fc8178e2664614b78322d2d05a70b9ac0a Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 11 Nov 2023 07:37:40 +0000 Subject: [PATCH] buflist: append: treat NULL additional buf as error not assert Very very occasionally on server we try to add a NULL buffer to a buflist. Let's try dealing with that by failing (caller must always be able to handle failure from OOM) rather than asserting. --- lib/core/buflist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/core/buflist.c b/lib/core/buflist.c index dbe544e5c8..4b50f92b01 100644 --- a/lib/core/buflist.c +++ b/lib/core/buflist.c @@ -39,7 +39,9 @@ lws_buflist_append_segment(struct lws_buflist **head, const uint8_t *buf, void *p = *head; int sanity = 1024; - assert(buf); + if (!buf) + return -1; + assert(len); /* append at the tail */