[ 
https://issues.apache.org/jira/browse/AXIS2C-1632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Lazarski resolved AXIS2C-1632.
-------------------------------------
    Fix Version/s: 2.0.0
                       (was: 1.7.0)
       Resolution: Fixed

 The hash table was storing pointers to keys without copying them,
    which caused:
    1. Memory leaks when callers strdup'd keys but couldn't track them
    2. Use-after-free when callers freed keys while hash still referenced them
    
    Fix by having the hash internally copy string keys (klen > 0):
    - Add key_is_copy flag to track internally managed keys
    - Copy keys in axutil_hash_find_entry when adding new entries
    - Free copied keys when entries are deleted or hash is freed
    - Update axutil_hash_copy and axutil_hash_merge to copy keys
    
    This allows callers to immediately free their key allocations after
    calling axutil_hash_set, as the hash now manages its own key copies.
    


> Patch to fix Stability issues and memory leaks on hash keys
> -----------------------------------------------------------
>
>                 Key: AXIS2C-1632
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-1632
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: core/engine
>            Reporter: Alex Mantaut
>            Priority: Major
>              Labels: patch
>             Fix For: 2.0.0
>
>         Attachments: axis2c-1632.patch, hash2_interface.patch
>
>
> Hash seems to keep a pointer to the keys of the elements it stores.Right now 
> that memory is managed by the caller of the method... In some cases it causes 
> a memory leak, but as the key memory is external to the hash it is a 
> potential segfault (I think this could be related to other existing segfaults 
> which are difficult to identify)
> I proposed a patch to create a copy of the key for the hash to use (the hash 
> releases that memory automatically when freed)...
> I looked trough all the code to correct the calls to axutil_hash_set() in 
> order to unify the memory management, and runned all the samples to check it 
> worked correctly (I know hash it's used in a lot of places)
> Please review the patch to see if any changes need to be done on it...



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to