diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Let a Lua script write while it loads
A script's top level runs before cgit hooks stdout for it, and the
unhook html() began with tripped an assert that aborted cgit.
Diffstat (limited to 'source')
| -rw-r--r-- | source/filter.c | 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 6 insertions, 2 deletions
diff --git a/source/filter.c b/source/filter.c index ec48007..b36f03e 100644 --- a/source/filter.c +++ b/source/filter.c @@ -225,15 +225,19 @@ static inline int emit_unfiltered(lua_State *lua_state, void (*emit)(const char if (!text) return 0; + // A script that writes while it is still loading runs before cgit has + // hooked stdout for it, so there is no hook to take off. saved_write = filter_write; saved_filter = current_write_filter; - unhook_write(); + if (saved_write) + unhook_write(); emit(text); // emit leaves bytes in the html buffer, so empty it while the hook is // still off. Re-hooking first would send the page's own bytes back into // the filter. html_flush(); - hook_write(saved_filter, saved_write); + if (saved_write) + hook_write(saved_filter, saved_write); return 0; } |
