From d7e17d2f1cb905f81c31bdbe15aac10c1d3d67a8 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Tue, 26 Aug 2014 17:31:57 +0200 Subject: [PATCH] Make sure multiple setup runs are ignored If the `configure` initializers or `startManager` are invoked multiple times, this can cause undefined behaviour and crashes. Hence we simply ignore if they are invoked multiple times. --- Classes/BITHockeyManager.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Classes/BITHockeyManager.m b/Classes/BITHockeyManager.m index 802deaa9a2..036f86eecd 100644 --- a/Classes/BITHockeyManager.m +++ b/Classes/BITHockeyManager.m @@ -88,6 +88,8 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h BOOL _startUpdateManagerIsInvoked; + BOOL _managersInitialized; + BITHockeyAppClient *_hockeyAppClient; } @@ -134,6 +136,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h if ((self = [super init])) { _serverURL = nil; _delegate = nil; + _managersInitialized = NO; _hockeyAppClient = nil; @@ -209,6 +212,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h - (void)startManager { if (!_validAppIdentifier) return; + if (_startManagerIsInvoked) return; if (![self isSetUpOnMainThread]) return; @@ -584,6 +588,8 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h } - (void)initializeModules { + if (_managersInitialized) return; + _validAppIdentifier = [self checkValidityOfAppIdentifier:_appIdentifier]; if (![self isSetUpOnMainThread]) return; @@ -628,6 +634,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h [self pingServerForIntegrationStartWorkflowWithTimeString:integrationFlowTime appIdentifier:_appIdentifier]; } } + _managersInitialized = YES; } else { [self logInvalidIdentifier:@"app identifier"]; }