[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#5060) slapi_entry_dup and leak

Full_Name: Martin Evans
Version: 2.3.37
OS: Linux/fc6
URL: ftp://ftp.openldap.org/incoming/addressbook.c
Submission from: (NULL) (

This problem seems similar to the solution suggested for ITS#4038. Id like to
add an attribute to an entry in the result set during a
SLAPI_PLUGIN_PRE_ENTRY_FN callback. According to 4038 the entry should be
dupped. But I cannot free the entry afterwards without problems, and if I dont
do that the server leaks memory at a high rate.

I've left an example plugin in your ftp incoming directory as addressbook.c. The
crucial bit of code is this:

   cn = slapi_entry_attr_get_charptr(e0, "cn");
   DEBUG("found: %s",cn);

   /* dup the entry - leaks!! */
   if (e1==NULL) {
     LOG("addressbook_result_entry failed to duplicate entry");
     return PLUGIN_STOP;


   /* set the dupped entry as the result */
   slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, e1);

   /* uncomment this for empty result set, otherwise leaks */

   /* uncomment this for crash */

If I free e1, I get null results via an ldap search (only "dn:" is displayed for
each entry. If I do that there is no leak.

If I free e0 (not sure what handles that after the pblock_set call) the server

Kind regards,