diff --git a/srcs/ft_free.c b/srcs/ft_free.c index cf8cadf..9f1fedb 100644 --- a/srcs/ft_free.c +++ b/srcs/ft_free.c @@ -6,7 +6,7 @@ /* By: thrieg < thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/11/19 15:44:05 by thrieg #+# #+# */ -/* Updated: 2025/12/08 15:53:31 by thrieg ### ########.fr */ +/* Updated: 2025/12/08 15:57:17 by thrieg ### ########.fr */ /* */ /* ************************************************************************** */ @@ -104,7 +104,7 @@ void free(void *ptr) pthread_mutex_unlock(&g_mut); return; // we didn't allocate this ptr } - pthread_mutex_unlock(&g_mut); if (g_state.patern) - ft_memset(ptr, g_state.patern ^ 0xFF, header->size); // doesn't need to lock because we only modify the user pointer and the user doesn't have accces to it yet + ft_memset(ptr, g_state.patern ^ 0xFF, header->size); // need to lock because this memory can be reallocated from another thread at any time (even before this function returns if we put it outside of lock) + pthread_mutex_unlock(&g_mut); }