diff --git a/Headers/Foundation/NSZone.h b/Headers/Foundation/NSZone.h
index 88f8bd9c8..dbcff8fa2 100644
--- a/Headers/Foundation/NSZone.h
+++ b/Headers/Foundation/NSZone.h
@@ -260,9 +260,10 @@ GSMakeWeakPointer(Class class, const char *iVarName);
* object. Apart from that case, a source needs to be garbage collectable for
* this function to work, and using a non-garbage collectable value will
* cause the function to return NO.
- * The destination object (watching the source object) must also be memory
- * allocated by the garbage colleector, and if it is not the function will
- * return NO.
+ * If the destination object (the weak pointer watching the source object)
+ * belongs to a chunk of memory which may be collected before the source
+ * object is collected, it is important that it is finalised and the
+ * finalisation code assigns zero to the pointer.
* If garbage collection is not in use, this function performs a simple
* assignment returning YES, unless destination is null in which case it
* returns NO.
diff --git a/Source/NSKeyValueObserving.m b/Source/NSKeyValueObserving.m
index 682ec81ca..205047415 100644
--- a/Source/NSKeyValueObserving.m
+++ b/Source/NSKeyValueObserving.m
@@ -810,6 +810,10 @@ replacementForClass(Class c)
{
GSMakeWeakPointer(self, "observer");
}
+- (void) finalize
+{
+ GSAssignZeroingWeakPointer((void**)&observer, nil);
+}
#endif
@end
diff --git a/Source/NSZone.m b/Source/NSZone.m
index ac18a27f9..13628d506 100644
--- a/Source/NSZone.m
+++ b/Source/NSZone.m
@@ -1910,9 +1910,9 @@ GSMakeWeakPointer(Class class, const char *iVarName)
BOOL
GSAssignZeroingWeakPointer(void **destination, void *source)
{
- if (GC_base(destination) == 0)
+ if (destination == 0)
{
- return NO; // Destination is not in garbage collection system.
+ return NO; // Bad destination pointer
}
if (*destination == source)
{