From b5259bcca17f601060d2d2e3abdc68646b7cf256 Mon Sep 17 00:00:00 2001 From: Evan Wies Date: Thu, 13 Feb 2014 22:03:16 -0500 Subject: Added nil check for tsfd in http_request() If the opening of the cache timestamp file fails, then tsfd would be nil. write is then invoked on it yielding: /usr/local/share/lua/5.1/luarocks/fs/lua.lua:592: attempt to index local 'tsfd' (a nil value) This changeset simply adds the check for nil. It does no further error reporting, so luarocks doesn't crash, but it also doesn't report that the cache was not updated nor that anything out of the ordinary happened. --- src/luarocks/fs/lua.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index a95e7c51..ea16b728 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -611,8 +611,10 @@ local function http_request(url, http, cached) if result then if cached and headers["last-modified"] then local tsfd = io.open(cached..".timestamp", "w") - tsfd:write(headers["last-modified"]) - tsfd:close() + if tsfd then + tsfd:write(headers["last-modified"]) + tsfd:close() + end end return table.concat(result) else -- cgit v1.2.3-55-g6feb