From c2fa2cbf8ef783863fe2d1f0e7c23580367035c4 Mon Sep 17 00:00:00 2001 From: Brian Ryner Date: Sun, 18 Dec 2022 14:23:01 +1100 Subject: [PATCH] Update comment --- disk/disk_darwin.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index fea6927..555ac36 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -24,7 +24,10 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro if err != nil { return ret, err } - fs = fs[:count] // Actual count may be less than from the first call. + // On 10.14, and possibly other OS versions, the actual count may + // be less than from the first call. Truncate to the returned count + // to prevent accessing uninitialized entries. + fs = fs[:count] for _, stat := range fs { opts := []string{"rw"} if stat.Flags&unix.MNT_RDONLY != 0 {