From cd45b48e8b9ff3e30fa13ea9b17b6d5a01a4b9d5 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 15 Oct 2010 02:43:46 -0300 Subject: Add sanity check to is_actual_binary. Should fix crash in 'luarocks pack' reported by Alexander Gladysh, or at least give better diagnostics. --- src/luarocks/fs/unix.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index f2290412..c5769bac 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua @@ -101,6 +101,11 @@ function is_actual_binary(filename) if file then local found = false local first = file:read() + if not first then + file:close() + print("Warning: could not read "..filename) + return false + end if first:match("#!.*lua") then file:close() return true -- cgit v1.2.3-55-g6feb