diff --git a/ChangeLog b/ChangeLog index c3323fa30..a5532ad95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-15 Wolfgang Lux + + * Source/NSMessagePort.m (-invalidate, -removeHandle:): Fix + potential crash while closing a message port. + 2008-11-14 Wolfgang Lux * Source/NSProcessInfo.m (-processorCount, -activeProcessorCount): diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index 970894abd..027641300 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -1571,7 +1571,11 @@ typedef struct { { if ([self isValid] == YES) { - M_LOCK(myLock); + /* Copy the lock into a local variable since the _internal structure + * may be freed during the call to [super invalidate] + */ + NSRecursiveLock *lock = ((internal*)_internal)->_myLock; + M_LOCK(lock); if ([self isValid] == YES) { @@ -1612,7 +1616,7 @@ typedef struct { [[NSMessagePortNameServer sharedInstance] removePort: self]; [super invalidate]; } - M_UNLOCK(myLock); + M_UNLOCK(lock); } } @@ -1716,7 +1720,11 @@ typedef struct { - (void) removeHandle: (GSMessageHandle*)handle { - M_LOCK(myLock); + /* Copy the lock into a local variable since the _internal structure + * may be freed during the call to [self invalidate] + */ + NSRecursiveLock *lock = ((internal*)_internal)->_myLock; + M_LOCK(lock); if ([handle sendPort] == self) { if (handle->caller != YES) @@ -1741,7 +1749,7 @@ typedef struct { { [self invalidate]; } - M_UNLOCK(myLock); + M_UNLOCK(lock); } /*