1
mirror of https://github.com/rclone/rclone synced 2024-12-01 10:31:57 +01:00

ncdu: fix crashes on empty directories - fixes #1910

Up arrow or right arrow in an empty directory would crash ncdu
This commit is contained in:
Nick Craig-Wood 2017-12-12 13:52:58 +00:00
parent 66558213e0
commit 2cf808c825

View File

@ -302,7 +302,7 @@ func (u *UI) move(d int) {
} }
// check dirPos.offset in bounds // check dirPos.offset in bounds
if dirPos.offset < 0 { if entries == 0 || dirPos.offset < 0 {
dirPos.offset = 0 dirPos.offset = 0
} else if dirPos.offset >= entries { } else if dirPos.offset >= entries {
dirPos.offset = entries - 1 dirPos.offset = entries - 1
@ -392,7 +392,7 @@ func (u *UI) setCurrentDir(d *scan.Dir) {
// enters the current entry // enters the current entry
func (u *UI) enter() { func (u *UI) enter() {
if u.d == nil { if u.d == nil || len(u.entries) == 0 {
return return
} }
dirPos := u.dirPosMap[u.path] dirPos := u.dirPosMap[u.path]