diff --git a/libs/console/client.c b/libs/console/client.c index ae3d0649a..c1a9f60ac 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -952,6 +952,7 @@ C_Init (void) static void C_shutdown (void) { + IE_Remove_Handler (con_event_id); } static general_funcs_t plugin_info_general_funcs = { diff --git a/libs/console/console.c b/libs/console/console.c index 5c7323fb0..b75884e71 100644 --- a/libs/console/console.c +++ b/libs/console/console.c @@ -57,6 +57,7 @@ static U void (*const display)(const char **, int) = Con_DisplayList; #undef U static cvar_t *con_interpreter; +static sys_printf_t saved_sys_printf; static void Con_Interp_f (cvar_t *var) @@ -89,6 +90,9 @@ Con_Interp_f (cvar_t *var) static void Con_shutdown (void *data) { + if (saved_sys_printf) { + Sys_SetStdPrintf (saved_sys_printf); + } if (con_module) { con_module->functions->general->shutdown (); PI_UnloadPlugin (con_module); @@ -102,7 +106,8 @@ Con_Init (const char *plugin_name) con_module = PI_LoadPlugin ("console", plugin_name); if (con_module) { - Sys_SetStdPrintf (con_module->functions->console->print); + __auto_type funcs = con_module->functions->console; + saved_sys_printf = Sys_SetStdPrintf (funcs->print); } else { setvbuf (stdout, 0, _IOLBF, BUFSIZ); } diff --git a/libs/util/sys.c b/libs/util/sys.c index 07ed52d05..25120aed2 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -247,6 +247,9 @@ VISIBLE sys_printf_t Sys_SetStdPrintf (sys_printf_t func) { sys_printf_t prev = sys_std_printf_function; + if (!func) { + func = Sys_StdPrintf; + } sys_std_printf_function = func; return prev; } @@ -255,6 +258,9 @@ VISIBLE sys_printf_t Sys_SetErrPrintf (sys_printf_t func) { sys_printf_t prev = sys_err_printf_function; + if (!func) { + func = Sys_ErrPrintf; + } sys_err_printf_function = func; return prev; }