From 1502b938e8b1da2b104a05cc5bb8f283fe95f77e Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Fri, 1 Apr 2022 22:46:57 +0000
Subject: [PATCH] Copy off the contact object for use in the result pointer

---
 xxmutils/restoreContacts.go | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/xxmutils/restoreContacts.go b/xxmutils/restoreContacts.go
index 1895fa128..f507af8ae 100644
--- a/xxmutils/restoreContacts.go
+++ b/xxmutils/restoreContacts.go
@@ -233,20 +233,23 @@ func LookupContact(userID *id.ID, udManager *ud.Manager,
 	var result *contact.Contact
 	var err error
 	lookupCB := func(c contact.Contact, myErr error) {
-		if myErr != nil {
+		if myErr == nil {
+			newOwnership := make([]byte, len(c.OwnershipProof))
+			copy(newOwnership, c.OwnershipProof)
+			newFacts, _, _ := fact.UnstringifyFactList(
+				c.Facts.Stringify())
+			result = &contact.Contact{
+				ID:             c.ID.DeepCopy(),
+				DhPubKey:       c.DhPubKey.DeepCopy(),
+				OwnershipProof: newOwnership,
+				Facts:          newFacts,
+			}
+		} else {
 			err = myErr
-		}
-		newOwnership := make([]byte, len(c.OwnershipProof))
-		copy(newOwnership, c.OwnershipProof)
-		newFacts, _, _ := fact.UnstringifyFactList(c.Facts.Stringify())
-		result = &contact.Contact{
-			ID:             c.ID.DeepCopy(),
-			DhPubKey:       c.DhPubKey.DeepCopy(),
-			OwnershipProof: newOwnership,
-			Facts:          newFacts,
+			result = nil
 		}
 		waiter.Unlock()
-		extLookupCB(*result, myErr)
+		extLookupCB(c, myErr)
 	}
 	// Take lock once to make sure I will wait
 	waiter.Lock()
-- 
GitLab