Skip to content

Commit f66b2e4

Browse files
committed
fix race condition
1 parent 0d2fdc1 commit f66b2e4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

graph/cert_node.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ package graph
33
import (
44
"fmt"
55
"strings"
6+
"sync"
67

78
"github.com/lanrat/certgraph/dns"
89
"github.com/lanrat/certgraph/fingerprint"
910
)
1011

1112
// CertNode graph node to store certificate information
1213
type CertNode struct {
13-
Fingerprint fingerprint.Fingerprint
14-
Domains []string
15-
foundMap map[string]bool
14+
Fingerprint fingerprint.Fingerprint
15+
Domains []string
16+
foundMap map[string]bool
17+
foundMapLock sync.Mutex
1618
}
1719

1820
func (c *CertNode) String() string {
@@ -30,6 +32,8 @@ func (c *CertNode) Found() []string {
3032

3133
// AddFound adds a driver name to the source of the certificate
3234
func (c *CertNode) AddFound(driver string) {
35+
c.foundMapLock.Lock()
36+
defer c.foundMapLock.Unlock()
3337
if c.foundMap == nil {
3438
c.foundMap = make(map[string]bool)
3539
}

0 commit comments

Comments
 (0)