From 8dcb0f808cb95bde63de9a4c5b1ba08b5d474fea Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 6 Jul 2021 15:41:18 -0700 Subject: Fix for UB (NULL pointer plus zero length). (#1459) --- src/core/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/message.c b/src/core/message.c index 52065bdd..2ff2d6da 100644 --- a/src/core/message.c +++ b/src/core/message.c @@ -110,7 +110,7 @@ nni_chunk_grow(nni_chunk *ch, size_t newsz, size_t headwanted) newsz = ch->ch_len; } - if ((ch->ch_ptr >= ch->ch_buf) && + if ((ch->ch_ptr >= ch->ch_buf) && (ch->ch_ptr != NULL) && (ch->ch_ptr < (ch->ch_buf + ch->ch_cap))) { size_t headroom = (size_t)(ch->ch_ptr - ch->ch_buf); if (headwanted < headroom) { -- cgit v1.2.3-70-g09d2