From 7bd68db7d702c5951d192359f2dd6b256a98c62d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 17 Nov 2014 14:25:51 +0100 Subject: modules/base: ltn12: source.file() should terminate when an empty chunk is read The read method of nixio's file and socket objects both return an empty string when they reach EOF, not nil, causing the consumer to loop endlessly as source.file() never terminates. As there is no other situation in which an empty chunk is read, just change it to nil to terminate the consumer's loop. Signed-off-by: Matthias Schiffer --- modules/base/luasrc/ltn12.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/base/luasrc/ltn12.lua b/modules/base/luasrc/ltn12.lua index 9371290c61..b59fb8c48a 100644 --- a/modules/base/luasrc/ltn12.lua +++ b/modules/base/luasrc/ltn12.lua @@ -144,6 +144,7 @@ function source.file(handle, io_err) if handle then return function() local chunk = handle:read(BLOCKSIZE) + if chunk and chunk:len() == 0 then chunk = nil end if not chunk then handle:close() end return chunk end -- cgit v1.2.3