From 073c7301ebdf7511320ec817ad7ecacf6b45c4be Mon Sep 17 00:00:00 2001
From: eaglegai <31752768+eaglegai@users.noreply.github.com>
Date: Tue, 21 Jan 2025 22:47:51 +0800
Subject: [PATCH] check before use daemon->shm_info (#1229)

fix core after the command `unbound-control stop unbound`

fix:https://github.com/NLnetLabs/unbound/issues/1228

Signed-off-by: eaglegai <eaglegai@163.com>
---
 util/shm_side/shm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/shm_side/shm_main.c b/util/shm_side/shm_main.c
index 6fd1f5ea6..751d6d649 100644
--- a/util/shm_side/shm_main.c
+++ b/util/shm_side/shm_main.c
@@ -195,7 +195,7 @@ void shm_main_shutdown(struct daemon* daemon)
 {
 #ifdef HAVE_SHMGET
 	/* web are OK, just disabled */
-	if(!daemon->cfg->shm_enable)
+	if(!daemon->cfg->shm_enable || !daemon->shm_info)
 		return;
 
 	verbose(VERB_DETAIL, "SHM shutdown - KEY [%d] - ID CTL [%d] ARR [%d] - PTR CTL [%p] ARR [%p]",
