From: Ekaitz Zárraga Date: Mon, 14 Sep 2015 11:31:49 +0000 (+0200) Subject: modules/luci-mod-failsafe: Fix nil file descriptor error X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a16654b12130d636b4e0f81839a26f5821619baa;p=oweals%2Fluci.git modules/luci-mod-failsafe: Fix nil file descriptor error Signed-off-by: Ekaitz Zárraga --- diff --git a/modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua b/modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua index 6f7864301..60caadb4b 100644 --- a/modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua +++ b/modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua @@ -84,11 +84,13 @@ function action_flashops() fp = io.open(image_tmp, "w") end end - if chunk then - fp:write(chunk) - end - if eof then - fp:close() + if fp then + if chunk then + fp:write(chunk) + end + if eof then + fp:close() + end end end )