]> source.dussan.org Git - gitea.git/commitdiff
Prevent panic on empty HOST for mysql (#11850) (#11856)
authorzeripath <art27@cantab.net>
Thu, 11 Jun 2020 18:27:59 +0000 (19:27 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2020 18:27:59 +0000 (14:27 -0400)
Backport #11850

Signed-off-by: Andrew Thornton <art27@cantab.net>
modules/setting/database.go

index 6bfb02ac41e6616088dc18794145c5a4b24d3795..4e84f8f8d19b89a4ac14617a6e0aaa34758ccf21 100644 (file)
@@ -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