From 38f34c266dc204094812d9e901507a865d441a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 27 Oct 2020 14:18:43 +0100 Subject: [PATCH] Fix possible NULL dereference in cd->dlz_destroy() If the call to cd->dlz_create() in dlopen_dlz_create() fails, cd->dbdata may be NULL when dlopen_dlz_destroy() gets called in the cleanup path and passing NULL to the cd->dlz_destroy() callback may cause a NULL dereference. Ensure that does not happen by checking whether cd->dbdata is non-NULL before calling the cd->dlz_destroy() callback. --- bin/named/unix/dlz_dlopen_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c index df11984970..e88ea6fc52 100644 --- a/bin/named/unix/dlz_dlopen_driver.c +++ b/bin/named/unix/dlz_dlopen_driver.c @@ -339,7 +339,7 @@ dlopen_dlz_destroy(void *driverarg, void *dbdata) { UNUSED(driverarg); - if (cd->dlz_destroy) { + if (cd->dlz_destroy && cd->dbdata) { MAYBE_LOCK(cd); cd->dlz_destroy(cd->dbdata); MAYBE_UNLOCK(cd);