Ticket #346 - Fixing memory leaks
Description:
There was a leak in attrlist_replace/attrlist_replace_with_flags
when attr_replace failed to replace the attribute values.
commit 708a56b8d524131362e2d71b7fbc2eb257075e14 for Ticket #47834
tried to fix it, but it was wrong and introduced a double free.
This patch fixes it so that ...
If attr_replace fails and if to be replaced Slapi_Attr is newly
created in attrlist_replace//attrlist_replace_with_flags, the
Slapi_Attr is removed from the attrlist (alist) and Slapi_Attr
is freed. Otherwise, values and Slapi_Attr are not freed since
Slapi_Attr is just pointing the attribute in the attrlist and
values are consumed in attr_replace.
https://fedorahosted.org/389/ticket/346
Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit c9b914b1610f6c03af4bcae9d311186807220068)
(cherry picked from commit b393c360499d001f0dd08de4d77d27a4e4f3048a)
(cherry picked from commit 3777f9c71bc53595d4d62a500da7a2897d056267)