From 934a8fc57b4fdff853c2fc313b79c83dfba1275c Mon Sep 17 00:00:00 2001 From: Enyby Date: Sun, 6 Oct 2019 23:49:04 +0300 Subject: [PATCH] Fix io.read(0) on EOF. --- src/core/org/luaj/vm2/lib/IoLib.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/org/luaj/vm2/lib/IoLib.java b/src/core/org/luaj/vm2/lib/IoLib.java index c757ce65..3bda6ce4 100644 --- a/src/core/org/luaj/vm2/lib/IoLib.java +++ b/src/core/org/luaj/vm2/lib/IoLib.java @@ -582,6 +582,7 @@ public class IoLib extends TwoArgFunction { // ------------- file reading utilitied ------------------ public static LuaValue freadbytes(File f, int count) throws IOException { + if (count == 0) return f.eof() ? NIL : EMPTYSTRING; byte[] b = new byte[count]; int r; if ( ( r = f.read(b,0,b.length) ) < 0 )