Merge pull request 'Make DelteProfile and ShutdownPeer safe to call twice / with incorrect onion' (#510) from fuzzbot into master
continuous-integration/drone/push Build is pending
Details
continuous-integration/drone/push Build is pending
Details
Reviewed-on: #510 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
70c335df81
13
app/app.go
13
app/app.go
|
@ -255,6 +255,12 @@ func (app *application) DeleteProfile(onion string, password string) {
|
|||
app.appmutex.Lock()
|
||||
defer app.appmutex.Unlock()
|
||||
|
||||
// short circuit to prevent nil-pointer panic if this function is called twice (or incorrectly)
|
||||
if app.peers[onion] == nil {
|
||||
log.Errorf("shutdownPeer called with invalid onion %v", onion)
|
||||
return
|
||||
}
|
||||
|
||||
// allow a blank password to delete "unencrypted" accounts...
|
||||
if password == "" {
|
||||
password = DefactoPasswordForUnencryptedProfiles
|
||||
|
@ -477,6 +483,13 @@ func (app *application) ShutdownPeer(onion string) {
|
|||
|
||||
// shutdownPeer mutex unlocked helper shutdown peer
|
||||
func (app *application) shutdownPeer(onion string) {
|
||||
|
||||
// short circuit to prevent nil-pointer panic if this function is called twice (or incorrectly)
|
||||
if app.eventBuses[onion] == nil || app.peers[onion] == nil {
|
||||
log.Errorf("shutdownPeer called with invalid onion %v", onion)
|
||||
return
|
||||
}
|
||||
|
||||
app.eventBuses[onion].Publish(event.NewEventList(event.ShutdownPeer, event.Identity, onion))
|
||||
app.eventBuses[onion].Shutdown()
|
||||
delete(app.eventBuses, onion)
|
||||
|
|
Loading…
Reference in New Issue