From a33476cf0081e2752f17594362ca26b964e09b49 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 4 Aug 2023 20:24:18 +1000 Subject: [PATCH] fix edge case where io.open(whatever):read() returns nil --- lib/libmtar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libmtar.lua b/lib/libmtar.lua index 4c40335..88d6b21 100644 --- a/lib/libmtar.lua +++ b/lib/libmtar.lua @@ -24,7 +24,7 @@ end function mtar.iter(stream) -- table -- function -- Given buffer *stream*, returns an iterator suitable for use with *for* that returns, for each iteration, the file name, a function to read from the file, and the length of the file. local remain = 0 local function read(n) - local rb = stream:read(math.min(n,remain)) + local rb = stream:read(math.min(n,remain)) or "" remain = remain - rb:len() return rb end