From c0b282576ecd9dc53cb43979f19fc5a97fe30f73 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Fri, 1 May 2026 22:26:45 +0300 Subject: [PATCH] Fix new Coverity Scan defect This adds checks in memory allocation, to address the following issue reported by coverity: ** CID 645850: Null pointer dereferences (FORWARD_NULL) /tests/ban-ips.c: 84 in main() Signed-off-by: default avatarDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- tests/ban-ips.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/ban-ips.c b/tests/ban-ips.c index fbddef72..7efc7880 100644 --- a/tests/ban-ips.c +++ b/tests/ban-ips.c @@ -72,12 +72,15 @@ int main(void) vhost = talloc_zero(s, struct vhost_cfg_st); if (vhost == NULL) exit(1); + vhost->config = talloc_zero(vhost, ReloadableConfig); - if (vhost->config != NULL) { - /* talloc_zero suffices for test-only field access; no pack/unpack needed */ - vhost->config->network = - talloc_zero(vhost->config, NetworkConfig); - } + if (vhost->config == NULL) + exit(1); + + /* talloc_zero suffices for test-only field access; no pack/unpack needed */ + vhost->config->network = talloc_zero(vhost->config, NetworkConfig); + if (vhost->config->network == NULL) + exit(1); list_add(s->vconfig, &vhost->list);