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: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=a16654b12130d636b4e0f81839a26f5821619baa;hp=6e1a089b5c765f3ab8a2029fa22c7be7ca0cae83;ds=sidebyside 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 )