diff --git a/app/app.go b/app/app.go index b9c1b8b..634f245 100644 --- a/app/app.go +++ b/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)