Skip to content

Commit

Permalink
Handle nil return value
Browse files Browse the repository at this point in the history
If list is nil, and we try to dereference it by doing list.ID, the code
panics. Instead, we should return a nil roster to the caller.
  • Loading branch information
kc1212 committed Feb 7, 2018
1 parent 73be916 commit 5e23f39
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package onet
import (
"errors"
"io/ioutil"
"net"
"os"
"strconv"
"time"

"net"

"github.com/dedis/kyber"
"github.com/dedis/kyber/util/key"
"github.com/dedis/onet/log"
Expand Down Expand Up @@ -168,6 +167,9 @@ func (l *LocalTest) GenRosterFromHost(servers ...*Server) *Roster {
entities = append(entities, servers[i].ServerIdentity)
}
list := NewRoster(entities)
if list == nil {
return nil
}
l.Rosters[list.ID] = list
return list
}
Expand Down

0 comments on commit 5e23f39

Please sign in to comment.