From fd0e8aa869ec74917d669d42f0e0d3b2888237b9 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 12 Jul 2020 13:40:21 +0200 Subject: [PATCH] tests: don't crash on empty Flistxattr result --- tests/xattr/xattr_fd_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/xattr/xattr_fd_test.go b/tests/xattr/xattr_fd_test.go index ad0b7ed..d3f02c5 100644 --- a/tests/xattr/xattr_fd_test.go +++ b/tests/xattr/xattr_fd_test.go @@ -42,7 +42,10 @@ func TestFdXattr(t *testing.T) { if sz != expectedSz { t.Errorf("expected size %d, got %d", expectedSz, sz) } - str := string(buf[:sz-1]) + str := "" + if sz > 0 { + str = string(buf[:sz-1]) + } if str != attr { t.Errorf("expected name %q, got %q", attr, str) }