check for nul pointer when destroying zone

This commit is contained in:
Richard Frith-Macdonald 2018-01-23 16:34:26 +00:00
parent 746f2a2a1a
commit cc97172bdd
2 changed files with 19 additions and 9 deletions

View file

@ -2,6 +2,7 @@
* Source/Additions/NSNumber+GNUstepBase.m:
* Source/GSValue.m:
* Source/NSZone.m:
* Tools/gdomap.c:
Fix various small issues picked by by automated checker.

View file

@ -497,18 +497,27 @@ static NSZone *zone_list = 0;
static inline void
destroy_zone(NSZone* zone)
{
if (zone_list == zone)
zone_list = zone->next;
else
if (zone)
{
NSZone *ptr = zone_list;
if (zone_list == zone)
{
zone_list = zone->next;
}
else
{
NSZone *ptr = zone_list;
while (ptr->next != zone)
ptr = ptr->next;
if (ptr)
ptr->next = zone->next;
while (ptr != NULL && ptr->next != zone)
{
ptr = ptr->next;
}
if (ptr)
{
ptr->next = zone->next;
}
}
free((void*)zone);
}
free((void*)zone);
}
/* Search the buffer to see if there is any memory chunks large enough