modules/luci-mod-failsafe: Fix nil file descriptor error 473/head
authorEkaitz Zárraga <ekaitz.zarraga@fon.com>
Mon, 14 Sep 2015 11:31:49 +0000 (13:31 +0200)
committerEkaitz Zárraga <ekaitz.zarraga@fon.com>
Mon, 14 Sep 2015 12:05:02 +0000 (14:05 +0200)
Signed-off-by: Ekaitz Zárraga <ekaitz.zarraga@fon.com>
modules/luci-mod-failsafe/luasrc/controller/failsafe/failsafe.lua

index 6f78643018ccdc95daf28524ba39903bc6ed806e..60caadb4b1fc498163dbcb8325a28f3b619fc2a8 100644 (file)
@@ -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
        )