fixed segfault in free (reading header type after munmap of the zone)
This commit is contained in:
parent
0384df02e9
commit
6bc3783b67
1 changed files with 6 additions and 4 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_free.c :+: :+: :+: */
|
/* ft_free.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: thrieg < thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/19 15:44:05 by thrieg #+# #+# */
|
/* Created: 2025/11/19 15:44:05 by thrieg #+# #+# */
|
||||||
/* Updated: 2025/12/08 15:57:17 by thrieg ### ########.fr */
|
/* Updated: 2025/12/13 06:52:01 by thrieg ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -92,12 +92,14 @@ void free(void *ptr)
|
||||||
else if (header->zone->type == E_SMALL)
|
else if (header->zone->type == E_SMALL)
|
||||||
{
|
{
|
||||||
header->occupied = false;
|
header->occupied = false;
|
||||||
defrag_zone(header->zone);
|
if (defrag_zone(header->zone))
|
||||||
|
return; //zone munmaped, avoid all other logic on this memory
|
||||||
}
|
}
|
||||||
else if (header->zone->type == E_TINY)
|
else if (header->zone->type == E_TINY)
|
||||||
{
|
{
|
||||||
header->occupied = false;
|
header->occupied = false;
|
||||||
defrag_zone(header->zone);
|
if (defrag_zone(header->zone))
|
||||||
|
return; //zone munmaped, avoid all other logic on this memory
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue