diff options
author | 2021-05-04 16:08:06 +0800 | |
---|---|---|
committer | 2021-05-04 10:08:06 +0200 | |
commit | b881a1ef1373f5abf85b2c1e434112107d5adeef (patch) | |
tree | a43461f7383e01976cf1be9c06e258201f627cc4 /plugin | |
parent | 40edf1e566a0b3709139420aeba542d9b788b1d0 (diff) | |
download | coredns-b881a1ef1373f5abf85b2c1e434112107d5adeef.tar.gz coredns-b881a1ef1373f5abf85b2c1e434112107d5adeef.tar.zst coredns-b881a1ef1373f5abf85b2c1e434112107d5adeef.zip |
Add error check to avoid panic (#4584)
* Add error check to avoid panic
Signed-off-by: Cookie Wang <luckymrwang@163.com>
* Add error check to avoid panic
Signed-off-by: Cookie Wang <luckymrwang@163.com>
Co-authored-by: Cookie Wang <luckymrwang@163.com>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/hosts/hostsfile.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go index 924c827da..cf3c43cc8 100644 --- a/plugin/hosts/hostsfile.go +++ b/plugin/hosts/hostsfile.go @@ -117,11 +117,14 @@ func (h *Hostsfile) readHosts() { defer file.Close() stat, err := file.Stat() + if err != nil { + return + } h.RLock() size := h.size h.RUnlock() - if err == nil && h.mtime.Equal(stat.ModTime()) && size == stat.Size() { + if h.mtime.Equal(stat.ModTime()) && size == stat.Size() { return } |