From 7541c20b6063c25124675271d68b00efb93c5cca Mon Sep 17 00:00:00 2001 From: Andrei Alexeyev Date: Wed, 21 Aug 2024 23:02:57 +0200 Subject: [PATCH] dynarray: make UBSan happy --- src/dynarray.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dynarray.c b/src/dynarray.c index 50b639d924..839287b561 100644 --- a/src/dynarray.c +++ b/src/dynarray.c @@ -84,6 +84,10 @@ void _dynarray_set_elements(dynarray_size_t sizeof_element, DynamicArray *darr, } void _dynarray_filter(dynarray_size_t sizeof_element, DynamicArray *darr, dynarray_filter_predicate_t predicate, void *userdata) { + if(UNLIKELY(!darr->data)) { + return; + } + char *p = darr->data; char *end = p + sizeof_element * darr->num_elements; dynarray_size_t shift = 0;