Prevent stack overflow if the logging handler is its own delegate.

This commit is contained in:
Hedden, Kyle Matthew 2024-01-26 14:03:01 -05:00
parent 84b00f7d19
commit d91dbbd460

View File

@ -36,6 +36,8 @@ import Foundation
@objc(addErrorToLog:)
open func addError(toLog errorObject: MVMCoreErrorObject) {
MVMCoreObject.sharedInstance()?.loggingDelegate?.addError(toLog: errorObject)
// Guard against doing anything further if the logging handler is its own delegate.
guard let loggingDelegate = MVMCoreObject.sharedInstance()?.loggingDelegate, loggingDelegate as? NSObject !== self else { return }
loggingDelegate.addError(toLog: errorObject)
}
}