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

Commit 9355bd6

Browse files
committed
Avoid getting the same default zone twice in a row.
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.
1 parent aab1c0a commit 9355bd6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/zone.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ register_zone(void)
246246
malloc_zone_register(&zone);
247247

248248
do {
249-
default_zone = malloc_default_zone();
250249
/*
251250
* Unregister and reregister the default zone. On OSX >= 10.6,
252251
* unregistering takes the last registered zone and places it
@@ -272,5 +271,7 @@ register_zone(void)
272271
malloc_zone_unregister(purgeable_zone);
273272
malloc_zone_register(purgeable_zone);
274273
}
275-
} while (malloc_default_zone() != &zone);
274+
275+
default_zone = malloc_default_zone();
276+
} while (default_zone != &zone);
276277
}

0 commit comments

Comments
 (0)