Several users have reported segfaults when starting up profanity which
has OMEMO support, but OMEMO is not set up yet.
@StefanKropp has been able to reproduce this and tracked it down to
`_load_identity()` calling `omemo_known_devices_keyfile_save()`.
The latter then calls `save_keyfile()` which calls
`g_key_file_save_to_file()`. This can then fail if one of the first two
strings is NULL and won't set the `error` on return. In its error handling
`save_keyfile()` unconditionally dereferences `error` which leads to the
segfault.
Fix this and also go through the entire codebase and verify that the usage
of `GError` is done correctly.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
In order to keep the C plugins API stable, we have to revert this part of
the changes done in 16ed7cc187.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Instead of always returning a `strdup()`'ed version, maybe return NULL and
handle this in the calling code.
This is still not true for `plugins_pre_chat_message_display()`, where we
return the passed `messag` in case there are no plugins, since this would
require a bigger refactor of more parts.
This also
* merges the implementation of `sv_ev_incoming_private_message()` and
`sv_ev_delayed_private_message()`, since they differed only by a single
line.
* untangles the `#ifdef` mess in `cl_ev_send_muc_msg_corrected()`.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* destroy/free/shutdown/close in reverse order of allocation
* more static/auto_Xfree
* less variables/strlen/GString
* properly `\0`-terminate string of testcase
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Instead of adding stuff to `_shutdown()`, we can now register a shutdown
routine from the respective `init()` function of our modules.
This also has the advantage, that we're sure they're called in reverse
order from how the initialization happened.
I didn't simply use `atexit()` because POSIX says that the number of
possible callbacks is limited (min 32) and I was not sure whether
we will maybe extend this number at one point.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
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>
Refactor function to enhance memory handling, addressing
temporary workaround introduced in 2e0adbd. Adjustments
ensure cleaner code and maintainability.
Part of the improvements suggested by @sjaeckel.
`/plugins reload non-existent-plugin` printed:
```
Failed to reload plugin: non-existent-plugin, `:^C
```
There were two mistakes:
error_message instead of error_message->str was passed to cons_show().
And in case of failing to unload the plugin due to not finding it in the
hash table it didn't print an error.
This bug was introduced in cc697de05.
In case Python or C plugins are disabled install/load failed silently.
Notify the user that we can't load them because profanity was built
without support for plugins.