Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Avoid getting the same default zone twice in a row.
Browse files Browse the repository at this point in the history
847ff22 added a call to malloc_default_zone() before the main loop in
register_zone, effectively making malloc_default_zone() called twice
without any different outcome expected in the returned result.

It is also called once at the beginning, and a second time at the end
of the loop block.

Instead, call it only once per iteration.
  • Loading branch information
glandium committed Jul 8, 2016
1 parent aab1c0a commit 9355bd6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/zone.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ register_zone(void)
malloc_zone_register(&zone);

do {
default_zone = malloc_default_zone();
/*
* Unregister and reregister the default zone. On OSX >= 10.6,
* unregistering takes the last registered zone and places it
Expand All @@ -272,5 +271,7 @@ register_zone(void)
malloc_zone_unregister(purgeable_zone);
malloc_zone_register(purgeable_zone);
}
} while (malloc_default_zone() != &zone);

default_zone = malloc_default_zone();
} while (default_zone != &zone);
}

0 comments on commit 9355bd6

Please sign in to comment.