aboutsummaryrefslogtreecommitdiff
path: root/src/weak/pointer.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/weak/pointer.go')
-rw-r--r--src/weak/pointer.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/weak/pointer.go b/src/weak/pointer.go
index 50af0c2fdc..39c512e76d 100644
--- a/src/weak/pointer.go
+++ b/src/weak/pointer.go
@@ -78,6 +78,9 @@ func Make[T any](ptr *T) Pointer[T] {
// If a weak pointer points to an object with a finalizer, then Value will
// return nil as soon as the object's finalizer is queued for execution.
func (p Pointer[T]) Value() *T {
+ if p.u == nil {
+ return nil
+ }
return (*T)(runtime_makeStrongFromWeak(p.u))
}