b393c36 Ticket #346 - Fixing memory leaks

Authored and Committed by nhosoi 9 years ago
    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)
    
        
file modified
+14 -5