]> git.sur5r.net Git - openldap/commitdiff
ITS#7735 plug memleak
authorHoward Chu <hyc@openldap.org>
Fri, 1 Nov 2013 18:07:51 +0000 (11:07 -0700)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 5 Nov 2013 19:16:47 +0000 (11:16 -0800)
Introduced in commit 48cdd54d9accb9283807ed592369b72654fb302d

servers/slapd/ldapsync.c
servers/slapd/proto-slap.h
servers/slapd/syncrepl.c

index 2c03ec7cb4a8d94bf705e84b3a980fb032b43462..753b5dc850b4d85aff046eb83d1f5658a777ba57 100644 (file)
@@ -370,6 +370,23 @@ slap_parse_sync_cookie(
        return 0;
 }
 
+/* count the numcsns and regenerate the list of SIDs in a recomposed cookie */
+void
+slap_reparse_sync_cookie(
+       struct sync_cookie *cookie,
+       void *memctx )
+{
+       if ( cookie->ctxcsn ) {
+               for (; !BER_BVISNULL( &cookie->ctxcsn[cookie->numcsns] ); cookie->numcsns++);
+       }
+       if ( cookie->numcsns ) {
+               cookie->sids = slap_parse_csn_sids( cookie->ctxcsn, cookie->numcsns,
+                       memctx );
+               if ( cookie->numcsns > 1 )
+                       slap_sort_csn_sids( cookie->ctxcsn, cookie->sids, cookie->numcsns, memctx );
+       }
+}
+
 int
 slap_init_sync_cookie_ctxcsn(
        struct sync_cookie *cookie
index 74b85c920ec3d73fe155d3d1bad0a4d49233477c..8f52214865408c5d2e896c1f0391dfd031189ab7 100644 (file)
@@ -1176,6 +1176,8 @@ LDAP_SLAPD_F (void) slap_insert_csn_sids LDAP_P((
                                struct sync_cookie *ck, int, int, struct berval * ));
 LDAP_SLAPD_F (int) slap_parse_sync_cookie LDAP_P((
                                struct sync_cookie *, void *memctx ));
+LDAP_SLAPD_F (int) slap_reparse_sync_cookie LDAP_P((
+                               struct sync_cookie *, void *memctx ));
 LDAP_SLAPD_F (int) slap_init_sync_cookie_ctxcsn LDAP_P((
                                struct sync_cookie * ));
 LDAP_SLAPD_F (struct sync_cookie *) slap_dup_sync_cookie LDAP_P((
index 5fe320d99e33a660817dc14f0a22cc37f820d691..1e6e00c049b611343ed9b633b34dfc4de1d9a420 100644 (file)
@@ -590,7 +590,8 @@ check_syncprov(
                slap_compose_sync_cookie( NULL, &si->si_syncCookie.octet_str,
                        si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
                        si->si_syncCookie.sid );
-               slap_parse_sync_cookie( &si->si_syncCookie, NULL );
+               ch_free( si->si_syncCookie.sids );
+               slap_reparse_sync_cookie( &si->si_syncCookie, op->o_tmpmemctx );
        }
        ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
        return changed;