diff --git a/CHANGES b/CHANGES
index dd9a32ce561a6f41a6bdc0d9a186bd24157e8e5e..88a843200b91b5d734d9f5a5e1cf9f22bd06cf4b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,7 @@ OpenLDAP 2.4.16 Engineering
 	Fixed libldap referral chasing (ITS#5980)
 	Fixed slapd backglue with empty DBs (ITS#5986)
 	Fixed slapd ctxcsn race condition (ITS#6001)
+	Fixed slapd debug message (ITS#6027)
 	Fixed slapd syncrepl newCookie sync messages (ITS#5972)
 	Fixed slapd syncrepl hang during shutdown (ITS#6011)
 	Fixed slapd syncrepl too many MMR messages (ITS#6020)
diff --git a/servers/slapd/at.c b/servers/slapd/at.c
index d4c4244b380344deda6dc4657e543b139b39e22b..59899b4395be5193790e463587cac91c577b8bfb 100644
--- a/servers/slapd/at.c
+++ b/servers/slapd/at.c
@@ -1080,10 +1080,10 @@ register_at( const char *def, AttributeDescription **rad, int dupok )
 			freeit = 1;
 
 		} else {
-			ldap_attributetype_free( at );
 			Debug( LDAP_DEBUG_ANY,
 				"register_at: AttributeType \"%s\": %s, %s\n",
 				def, scherr2str(code), err );
+			ldap_attributetype_free( at );
 			return code;
 		}
 	}