From: Martin Willi Date: Wed, 6 Nov 2013 09:09:04 +0000 (+0100) Subject: leak-detective: Register OS X specific hooks just once X-Git-Tag: 5.1.2dr1~33^2~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef6d78d6ef0c84ff19753cf5f72fa1514d525af7;p=thirdparty%2Fstrongswan.git 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. --- diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c index 87e21bb463..16e0237906 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) {