Full_Name: Martin Evans Version: 2.3.37 OS: Linux/fc6 URL: ftp://ftp.openldap.org/incoming/addressbook.c Submission from: (NULL) (138.37.8.140)
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:
slapi_pblock_get(pb,SLAPI_SEARCH_RESULT_ENTRY,&e0); cn = slapi_entry_attr_get_charptr(e0, "cn"); DEBUG("found: %s",cn);
/* dup the entry - leaks!! */ e1=slapi_entry_dup(e0); if (e1==NULL) { LOG("addressbook_result_entry failed to duplicate entry"); return PLUGIN_STOP; }
slapi_entry_attr_set_charptr(e1,"telephoneNumber","12345");
/* set the dupped entry as the result */ slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, e1);
/* uncomment this for empty result set, otherwise leaks */ //slapi_entry_free(e1);
/* uncomment this for crash */ //slapi_entry_free(e0);
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 crashes.
Kind regards, Martin.