From ef6d78d6ef0c84ff19753cf5f72fa1514d525af7 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Wed, 6 Nov 2013 10:09:04 +0100 Subject: [PATCH] leak-detective: Register OS X specific hooks just once If we initialize libstrongswan more than once in the same process, we may not register the hooks twice. --- src/libstrongswan/utils/leak_detective.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c index 87e21bb46..16e023790 100644 --- a/src/libstrongswan/utils/leak_detective.c +++ b/src/libstrongswan/utils/leak_detective.c @@ -333,9 +333,16 @@ HOOK(size_t, size, const void *ptr) */ static bool register_hooks() { + static bool once = FALSE; malloc_zone_t *zone; void *page; + if (once) + { + return TRUE; + } + once = TRUE; + zone = malloc_default_zone(); if (zone->version != MALLOC_ZONE_VERSION) {