From b224c946835e9523bb8cd125718027f68843d30e Mon Sep 17 00:00:00 2001 From: Nick Khyl Date: Wed, 23 Apr 2025 09:35:14 -0500 Subject: [PATCH] net/portmapper: fix nil pointer dereference in Client.createMapping The EventBus in net/portmapper.Config is still optional and Client.updates can be nil. Updates #15772 Signed-off-by: Nick Khyl --- net/portmapper/portmapper.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/portmapper/portmapper.go b/net/portmapper/portmapper.go index f95d6503a..59f88e966 100644 --- a/net/portmapper/portmapper.go +++ b/net/portmapper/portmapper.go @@ -508,11 +508,13 @@ func (c *Client) createMapping() { } return } - c.updates.Publish(Mapping{ - External: mapping.External(), - Type: mapping.MappingType(), - GoodUntil: mapping.GoodUntil(), - }) + if c.updates != nil { + c.updates.Publish(Mapping{ + External: mapping.External(), + Type: mapping.MappingType(), + GoodUntil: mapping.GoodUntil(), + }) + } if c.onChange != nil { go c.onChange() }