From 6a723e5a87ea754c02f5229973915230d76ac688 Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 17 Nov 2024 16:41:59 +0000 Subject: [PATCH] Fixes for dealloc when init has not been called. --- Source/Additions/GSMime.m | 2 +- Source/NSConnection.m | 2 +- Source/NSDateFormatter.m | 2 +- Source/NSNumberFormatter.m | 2 +- Source/NSOperation.m | 19 +++++++++++-------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 9c69887c8..1c7dfc140 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -8440,7 +8440,7 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient) - (void) dealloc { [self abort]; - if (internal != nil) + if (GS_EXISTS_INTERNAL) { DESTROY(internal->reply); DESTROY(internal->wdata); diff --git a/Source/NSConnection.m b/Source/NSConnection.m index 590ff1986..de9fd966c 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -857,7 +857,7 @@ static NSLock *cached_proxies_gate = nil; if (debug_connection) NSLog(@"deallocating %@", self); [self finalize]; - if (internal != nil) + if (GS_EXISTS_INTERNAL) { GS_DESTROY_INTERNAL(NSConnection); } diff --git a/Source/NSDateFormatter.m b/Source/NSDateFormatter.m index 46ac499c5..4651a1a71 100644 --- a/Source/NSDateFormatter.m +++ b/Source/NSDateFormatter.m @@ -155,7 +155,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0; - (void) dealloc { RELEASE(_dateFormat); - if (internal != 0) + if (GS_EXISTS_INTERNAL) { RELEASE(internal->_locale); RELEASE(internal->_tz); diff --git a/Source/NSNumberFormatter.m b/Source/NSNumberFormatter.m index 9f2488976..710924d2c 100644 --- a/Source/NSNumberFormatter.m +++ b/Source/NSNumberFormatter.m @@ -559,7 +559,7 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4; RELEASE(_attributedStringForNil); RELEASE(_attributedStringForNotANumber); RELEASE(_attributedStringForZero); - if (internal != 0) + if (GS_EXISTS_INTERNAL) { int idx; diff --git a/Source/NSOperation.m b/Source/NSOperation.m index fb7584a4b..08590329a 100644 --- a/Source/NSOperation.m +++ b/Source/NSOperation.m @@ -193,7 +193,7 @@ static void *queuePriorityCtxt = (void*)"queuePriority"; { /* Only clean up if ivars have been initialised */ - if (internal && internal->lock) + if (GS_EXISTS_INTERNAL) { NSOperation *op; @@ -800,13 +800,16 @@ static NSOperationQueue *mainQueue = nil; - (void) dealloc { [self cancelAllOperations]; - DESTROY(internal->operations); - DESTROY(internal->starting); - DESTROY(internal->waiting); - DESTROY(internal->name); - DESTROY(internal->cond); - DESTROY(internal->lock); - GS_DESTROY_INTERNAL(NSOperationQueue); + if (GS_EXISTS_INTERNAL) + { + DESTROY(internal->operations); + DESTROY(internal->starting); + DESTROY(internal->waiting); + DESTROY(internal->name); + DESTROY(internal->cond); + DESTROY(internal->lock); + GS_DESTROY_INTERNAL(NSOperationQueue); + } [super dealloc]; }