Skip to content

Commit

Permalink
Improve shutdown
Browse files Browse the repository at this point in the history
1. close logfile as last action
2. Fix `plugins_shutdown()` accessing `((ProfPlugin*)curr->data)->lang`
   after `curr->data` had already potentially been free'd.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
  • Loading branch information
sjaeckel committed Dec 9, 2023
1 parent fa59872 commit 446f6e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/plugins/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,21 +932,23 @@ void
plugins_shutdown(void)
{
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
GList *curr = values, *next;

while (curr) {
next = g_list_next(curr);
#ifdef HAVE_PYTHON
if (((ProfPlugin*)curr->data)->lang == LANG_PYTHON) {
if (curr && ((ProfPlugin*)curr->data)->lang == LANG_PYTHON) {
python_plugin_destroy(curr->data);
curr = NULL;
}
#endif
#ifdef HAVE_C
if (((ProfPlugin*)curr->data)->lang == LANG_C) {
if (curr && ((ProfPlugin*)curr->data)->lang == LANG_C) {
c_plugin_destroy(curr->data);
curr = NULL;
}
#endif

curr = g_list_next(curr);
curr = next;
}
g_list_free(values);
#ifdef HAVE_PYTHON
Expand Down
2 changes: 1 addition & 1 deletion src/profanity.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ _shutdown(void)
accounts_close();
tlscerts_close();
log_stderr_close();
log_close();
plugins_shutdown();
cmd_uninit();
ui_close();
prefs_close();
log_close();
}

0 comments on commit 446f6e6

Please sign in to comment.