From 6b1e5f7f88d13bb651de715bc3f447df94b9d6a3 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 11 Jun 2020 19:27:59 +0100 Subject: [PATCH] Prevent panic on empty HOST for mysql (#11850) (#11856) Backport #11850 Signed-off-by: Andrew Thornton --- modules/setting/database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setting/database.go b/modules/setting/database.go index 6bfb02ac4..4e84f8f8d 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -105,7 +105,7 @@ func DBConnStr() (string, error) { switch Database.Type { case "mysql": connType := "tcp" - if Database.Host[0] == '/' { // looks like a unix socket + if len(Database.Host) > 0 && Database.Host[0] == '/' { // looks like a unix socket connType = "unix" } tls := Database.SSLMode