From 149c5f9117aebda1dcb0cd726f251edf0212b8f3 Mon Sep 17 00:00:00 2001 From: Chteufleur Date: Thu, 11 Aug 2016 19:49:21 +0200 Subject: [PATCH] Fix nil pointer on database.GetLine() --- database/database.go | 2 +- xmpp/commands.go | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/database/database.go b/database/database.go index 8cd966e..2433737 100644 --- a/database/database.go +++ b/database/database.go @@ -132,7 +132,7 @@ func RemoveLine(jid string) bool { func GetLine(jid string) *DatabaseLine { ret := getLine(jid) - if ret.SteamLogin == "" { + if ret == nil || ret.SteamLogin == "" { log.Printf("%sLine empty", LogDebug) return nil } diff --git a/xmpp/commands.go b/xmpp/commands.go index dfcb348..ab1a497 100644 --- a/xmpp/commands.go +++ b/xmpp/commands.go @@ -108,18 +108,22 @@ func execCommandAdHoc(iq *xmpp.Iq) { jidBare := strings.SplitN(iq.From, "/", 2)[0] dbUser := database.GetLine(jidBare) - dbUser.Debug = !dbUser.Debug - g := MapGatewayInfo[jidBare] - ok := dbUser.UpdateLine() - if ok && g != nil { - g.DebugMessage = dbUser.Debug - if dbUser.Debug { - note.Value = "Debug activated." + if dbUser != nil { + dbUser.Debug = !dbUser.Debug + g := MapGatewayInfo[jidBare] + ok := dbUser.UpdateLine() + if ok && g != nil { + g.DebugMessage = dbUser.Debug + if dbUser.Debug { + note.Value = "Debug activated." + } else { + note.Value = "Debug desactivated." + } } else { - note.Value = "Debug desactivated." + note.Value = "Failed to update your profile. :(" } } else { - note.Value = "Failed to update your profile. :(" + note.Value = "Your not registered." } cmd.Note = *note