diff options
-rw-r--r-- | apps/plugins/lua/lzio.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/apps/plugins/lua/lzio.c b/apps/plugins/lua/lzio.c index 293edd59b0..54d5ec4741 100644 --- a/apps/plugins/lua/lzio.c +++ b/apps/plugins/lua/lzio.c | |||
@@ -22,10 +22,15 @@ int luaZ_fill (ZIO *z) { | |||
22 | size_t size; | 22 | size_t size; |
23 | lua_State *L = z->L; | 23 | lua_State *L = z->L; |
24 | const char *buff; | 24 | const char *buff; |
25 | if (!z->reader) | ||
26 | return EOZ; | ||
25 | lua_unlock(L); | 27 | lua_unlock(L); |
26 | buff = z->reader(L, z->data, &size); | 28 | buff = z->reader(L, z->data, &size); |
27 | lua_lock(L); | 29 | lua_lock(L); |
28 | if (buff == NULL || size == 0) return EOZ; | 30 | if (buff == NULL || size == 0) { |
31 | z->reader = NULL; /* avoid calling reader function next time */ | ||
32 | return EOZ; | ||
33 | } | ||
29 | z->n = size - 1; | 34 | z->n = size - 1; |
30 | z->p = buff; | 35 | z->p = buff; |
31 | return char2int(*(z->p++)); | 36 | return char2int(*(z->p++)); |