openldap: Fixed possible dereference of NULL pointer
authorPavel Rochnyack <pavel2000@ngs.ru>
Mon, 24 Jul 2017 07:05:16 +0000 (14:05 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Mon, 24 Jul 2017 07:07:27 +0000 (14:07 +0700)
If `plugin_register_complex_read()` has failed, then `cldap_free` is called which set pointer to NULL.
That pointer is accessed by `cldap_shutdown()` callback later.

src/openldap.c

index b3fcb10..227c8e1 100644 (file)
@@ -535,7 +535,7 @@ static int cldap_init(void) /* {{{ */
 static int cldap_shutdown(void) /* {{{ */
 {
   for (size_t i = 0; i < databases_num; i++)
-    if (databases[i]->ld != NULL)
+    if (databases[i] != NULL && databases[i]->ld != NULL)
       ldap_unbind_ext_s(databases[i]->ld, NULL, NULL);
   sfree(databases);
   databases_num = 0;