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>
This commit is contained in:
Dimitri Papadopoulos Orfanos
2026-05-01 19:26:45 +00:00
committed by Nikos Mavrogiannopoulos
parent ac5ee6a10b
commit c0b282576e
+8 -5
View File
@@ -72,12 +72,15 @@ int main(void)
vhost = talloc_zero(s, struct vhost_cfg_st); vhost = talloc_zero(s, struct vhost_cfg_st);
if (vhost == NULL) if (vhost == NULL)
exit(1); exit(1);
vhost->config = talloc_zero(vhost, ReloadableConfig); vhost->config = talloc_zero(vhost, ReloadableConfig);
if (vhost->config != NULL) { if (vhost->config == NULL)
/* talloc_zero suffices for test-only field access; no pack/unpack needed */ exit(1);
vhost->config->network =
talloc_zero(vhost->config, NetworkConfig); /* 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); list_add(s->vconfig, &vhost->list);