[mod_magnet] reset after error attaching content

reset after error raised attaching content

(The lua stack has been unwound after the exception)
(Might avoid reloading script if an alt env is used; not tested)
personal/stbuehler/tests-path
Glenn Strauss 2022-02-10 15:15:36 -05:00
parent d0273c8af5
commit 5c9eb60c8c
1 changed files with 4 additions and 1 deletions

View File

@ -2413,7 +2413,10 @@ static handler_t magnet_attract(request_st * const r, plugin_data * const p, scr
r->handler_module = p->self;
}
} else {
lua_settop(L, 2); /* remove all but function and lighty table */
if (lua_gettop(L) > 2)
lua_settop(L, 2); /* remove all but function and lighty table */
else if (lua_gettop(L) != 2)
lua_settop(L, 0); /* throw everything away; force script reload */
r->http_status = 500;
r->handler_module = NULL;
http_response_body_clear(r, 0);