Browse Source

Fix the crash in #69

Tulir Asokan 6 years ago
parent
commit
5be78dd978
2 changed files with 6 additions and 0 deletions
  1. 3 0
      portal.go
  2. 3 0
      puppet.go

+ 3 - 0
portal.go

@@ -79,6 +79,9 @@ func (bridge *Bridge) dbPortalsToPortals(dbPortals []*database.Portal) []*Portal
 	defer bridge.portalsLock.Unlock()
 	output := make([]*Portal, len(dbPortals))
 	for index, dbPortal := range dbPortals {
+		if dbPortal == nil {
+			continue
+		}
 		portal, ok := bridge.portalsByJID[dbPortal.Key]
 		if !ok {
 			portal = bridge.loadDBPortal(dbPortal, nil)

+ 3 - 0
puppet.go

@@ -107,6 +107,9 @@ func (bridge *Bridge) dbPuppetsToPuppets(dbPuppets []*database.Puppet) []*Puppet
 	defer bridge.puppetsLock.Unlock()
 	output := make([]*Puppet, len(dbPuppets))
 	for index, dbPuppet := range dbPuppets {
+		if dbPuppet == nil {
+			continue
+		}
 		puppet, ok := bridge.puppets[dbPuppet.JID]
 		if !ok {
 			puppet = bridge.NewPuppet(dbPuppet)