diff options
author | Evan Wies <evan@neomantra.net> | 2014-02-13 22:03:16 -0500 |
---|---|---|
committer | Evan Wies <evan@neomantra.net> | 2014-02-13 22:03:16 -0500 |
commit | b5259bcca17f601060d2d2e3abdc68646b7cf256 (patch) | |
tree | 86ab4426575049dacf28ab768f7158d8593e8536 | |
parent | 2f23df7e40e5750148d0e619f8d1a314e594ccc9 (diff) | |
download | luarocks-b5259bcca17f601060d2d2e3abdc68646b7cf256.tar.gz luarocks-b5259bcca17f601060d2d2e3abdc68646b7cf256.tar.bz2 luarocks-b5259bcca17f601060d2d2e3abdc68646b7cf256.zip |
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.
-rw-r--r-- | src/luarocks/fs/lua.lua | 6 |
1 files 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) | |||
611 | if result then | 611 | if result then |
612 | if cached and headers["last-modified"] then | 612 | if cached and headers["last-modified"] then |
613 | local tsfd = io.open(cached..".timestamp", "w") | 613 | local tsfd = io.open(cached..".timestamp", "w") |
614 | tsfd:write(headers["last-modified"]) | 614 | if tsfd then |
615 | tsfd:close() | 615 | tsfd:write(headers["last-modified"]) |
616 | tsfd:close() | ||
617 | end | ||
616 | end | 618 | end |
617 | return table.concat(result) | 619 | return table.concat(result) |
618 | else | 620 | else |