瀏覽代碼

Fix crashing bug when targeting to regions and city database returns nil

Ask Bjørn Hansen 12 年之前
父節點
當前提交
0c23ff73f5
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      geoip.go

+ 3 - 0
geoip.go

@@ -42,6 +42,9 @@ func (g *GeoIP) GetCountryRegion(ip net.IP) (country, continent, regionGroup, re
 	}
 	}
 
 
 	record := geoIP.city.GetRecord(ip.String())
 	record := geoIP.city.GetRecord(ip.String())
+	if record == nil {
+		return
+	}
 
 
 	country = record.CountryCode
 	country = record.CountryCode
 	region = record.Region
 	region = record.Region