summaryrefslogtreecommitdiff
path: root/exports/disco.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-04-17 11:52:19 +0200
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2023-04-18 14:05:19 +0200
commit7f745d11aaf6b5be660771ed2eb0ef86ab6eb60f (patch)
tree9e330d1f6b3865cb8b801390344f6e3534148fc2 /exports/disco.go
parent0216a88ff88cf600083eaf64bbf98c373bc376a4 (diff)
Exports Disco: Safeguard against nil servers/organizations
Diffstat (limited to 'exports/disco.go')
-rw-r--r--exports/disco.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/exports/disco.go b/exports/disco.go
index 5fd027c..08c921f 100644
--- a/exports/disco.go
+++ b/exports/disco.go
@@ -176,6 +176,10 @@ func GetDiscoServers(name *C.char) (*C.discoveryServers, *C.error) {
return nil, getError(stateErr)
}
servers, serversErr := state.DiscoServers()
+ // if we get no servers then we return immediately
+ if servers == nil {
+ return nil, getError(serversErr)
+ }
returnedStruct := (*C.discoveryServers)(
C.malloc(C.size_t(unsafe.Sizeof(C.discoveryServers{}))),
)
@@ -195,6 +199,10 @@ func GetDiscoOrganizations(name *C.char) (*C.discoveryOrganizations, *C.error) {
return nil, getError(stateErr)
}
organizations, organizationsErr := state.DiscoOrganizations()
+ // if we get no organizations then we return immediately
+ if organizations == nil {
+ return nil, getError(organizationsErr)
+ }
returnedStruct := (*C.discoveryOrganizations)(
C.malloc(C.size_t(unsafe.Sizeof(C.discoveryOrganizations{}))),
)