diff --git a/CHANGES b/CHANGES
index a79108bb1462677a03fd7198a572bc74fb1cfde1..bd522cf07ceaa027a5b177182d152d2afa275edf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@ OpenLDAP 2.4.16 Engineering
 	Fixed libldap segfault in checking cert/DN (ITS#5976)
 	Fixed slapd-ldap/meta with broken AD results (ITS#5977)
 	Fixed slapd-ldap/meta with invalid attrs again (ITS#5959)
+	Fixed slapo-accesslog interaction with ppolicy (ITS#5979)
 
 OpenLDAP 2.4.15 Release (2009/02/24)
 	Fixed libldap alias dereferencing in C API again (ITS#5916)
diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c
index 2ddfc1fd84e0f73203b0a6e1f7ae2293dce7ac7f..967d56fd18ad24b1ea02647ee26b1c85f3db5009 100644
--- a/servers/slapd/overlays/accesslog.c
+++ b/servers/slapd/overlays/accesslog.c
@@ -1551,22 +1551,24 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
 					i += a->a_numvals;
 				}
 			}
-			vals = ch_malloc( (i + 1) * sizeof( struct berval ) );
-			i = 0;
-			for ( a=old->e_attrs; a; a=a->a_next ) {
-				if ( a->a_vals && a->a_flags ) {
-					for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
-						accesslog_val2val( a->a_desc, b, 0, &vals[i] );
+			if ( i ) {
+				vals = ch_malloc( (i + 1) * sizeof( struct berval ) );
+				i = 0;
+				for ( a=old->e_attrs; a; a=a->a_next ) {
+					if ( a->a_vals && a->a_flags ) {
+						for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
+							accesslog_val2val( a->a_desc, b, 0, &vals[i] );
+						}
 					}
 				}
+				vals[i].bv_val = NULL;
+				vals[i].bv_len = 0;
+				a = attr_alloc( ad_reqOld );
+				a->a_numvals = i;
+				a->a_vals = vals;
+				a->a_nvals = vals;
+				last_attr->a_next = a;
 			}
-			vals[i].bv_val = NULL;
-			vals[i].bv_len = 0;
-			a = attr_alloc( ad_reqOld );
-			a->a_numvals = i;
-			a->a_vals = vals;
-			a->a_nvals = vals;
-			last_attr->a_next = a;
 		}
 		if ( logop == LOG_EN_MODIFY ) {
 			break;