From 0a4049767a2f9faf27f17d71325943eb82209b95 Mon Sep 17 00:00:00 2001 From: Erant Date: Sat, 14 Mar 2015 09:00:25 -0700 Subject: [PATCH] Fix getFSF to abide by the function contract --- app/lua/lauxlib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/lua/lauxlib.c b/app/lua/lauxlib.c index fedd7c56..e9f8f30a 100644 --- a/app/lua/lauxlib.c +++ b/app/lua/lauxlib.c @@ -659,13 +659,19 @@ typedef struct LoadFSF { static const char *getFSF (lua_State *L, void *ud, size_t *size) { LoadFSF *lf = (LoadFSF *)ud; (void)L; + + if (L == NULL && size == NULL) // Direct mode check + return NULL; + if (lf->extraline) { lf->extraline = 0; *size = 1; return "\n"; } + if (fs_eof(lf->f)) return NULL; *size = fs_read(lf->f, lf->buff, sizeof(lf->buff)); + return (*size > 0) ? lf->buff : NULL; }