summaryrefslogtreecommitdiff
path: root/apps/plugins/lua
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua')
-rw-r--r--apps/plugins/lua/lzio.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/apps/plugins/lua/lzio.c b/apps/plugins/lua/lzio.c
index 293edd5..54d5ec4 100644
--- a/apps/plugins/lua/lzio.c
+++ b/apps/plugins/lua/lzio.c
@@ -22,10 +22,15 @@ int luaZ_fill (ZIO *z) {
size_t size;
lua_State *L = z->L;
const char *buff;
+ if (!z->reader)
+ return EOZ;
lua_unlock(L);
buff = z->reader(L, z->data, &size);
lua_lock(L);
- if (buff == NULL || size == 0) return EOZ;
+ if (buff == NULL || size == 0) {
+ z->reader = NULL; /* avoid calling reader function next time */
+ return EOZ;
+ }
z->n = size - 1;
z->p = buff;
return char2int(*(z->p++));