From 6f8b3544b95e21c46521ba071d16fb4ac10ae5d8 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 13 Jan 2023 13:15:21 -0800 Subject: [PATCH] shared/bap: Fix scan-build warning This fixes the following warning: src/shared/bap.c:2268:26: warning: Access to field 'iov_len' results in a dereference of a null pointer (loaded from variable 'cont') return iov_append(data, cont->iov_len, cont->iov_base); ^~~~~~~~~~~~~ --- src/shared/bap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index 0cafb75e6..88697988e 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2261,6 +2261,12 @@ static void *ltv_merge(struct iovec *data, struct iovec *cont) { uint8_t delimiter = 0; + if (!data) + return NULL; + + if (!cont || !cont->iov_len || !cont->iov_base) + return data->iov_base; + iov_append(data, sizeof(delimiter), &delimiter); return iov_append(data, cont->iov_len, cont->iov_base); -- 2.47.3