7658 Commits

Author SHA1 Message Date
Steffen Jaeckel
25184a53e0 Improve const correctness.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-13 15:07:39 +01:00
Steffen Jaeckel
666895905b Revert API change of plugins_pre_chat_message_display()
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>
2025-03-13 13:28:06 +01:00
Steffen Jaeckel
a9c601101d Simplify code
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-13 13:02:13 +01:00
Steffen Jaeckel
4940218257 Minimize strdup() operations in plugins.
Instead of dup'ing each string before free'ing it, simply re-use the same.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-13 13:01:36 +01:00
Michael Vetter
5b9516b483 Merge pull request #2022 from profanity-im/fixes
Memory fixes
2025-03-13 09:58:09 +01:00
Michael Vetter
bf24d79990 Add plist to gitignore 2025-03-13 09:48:32 +01:00
Michael Vetter
71b7d97dcb Get rid of unused define 2025-03-13 09:48:32 +01:00
Michael Vetter
b5f0cc0bd4 Fix more potential leaks in aesgcm_download 2025-03-13 09:48:27 +01:00
Michael Vetter
0da47064b5 Merge pull request #2023 from profanity-im/debug-1946-1994
Some more fixes & improvements
2025-03-13 09:32:37 +01:00
Steffen Jaeckel
edb41bef60 Re-factor notifier.
* Add an internal `_notifier_uninit()` function.
* Instead of `#ifdef` inside `notify()`, provide different target-specific
static implementations.

This also introduces `log_error_once()`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-12 10:15:39 +01:00
Steffen Jaeckel
00d50d457c Let's use Debian as reference Valgrind platform
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-12 10:15:39 +01:00
Steffen Jaeckel
ef476cbf96 Cancel all running build jobs on force-push of a PR branch
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-12 10:15:39 +01:00
Steffen Jaeckel
79dfe2bba2 Don't error-out if Valgrind fails
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-12 10:15:39 +01:00
Steffen Jaeckel
83a4165d92 plugins_(on|pre) API now maybe returns NULL.
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>
2025-03-12 10:15:35 +01:00
Steffen Jaeckel
95c2199ca2 Some more memory improvements
* Less leaks
* Less allocations

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-12 10:09:41 +01:00
Steffen Jaeckel
9fc0326428 Add Valgrind to CI
* Also pass `$*` to `configure` when invoking `ci-build.sh`, so one can
  e.g. run `./ci-build.sh --without-xscreensaver`

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-11 12:15:09 +01:00
Steffen Jaeckel
c0da36c48d Rage-cleanup.
While trying to get the unit tests working again I stumbled over all those
things that I thought could be better^TM.

Now we also know "TODO: why does this make the test fail?" - because
the unit tests are brittle AF ... and we have to init the subsystems
we use in the test, otherwise the cleanup will fail...

BTW. you can now also only run a single test ... or a pattern or so ...
you'd have to read how `cmocka_set_test_filter()` works exactly.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-10 11:45:15 +01:00
Steffen Jaeckel
72b99ceb6d Some minor improvements
* 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>
2025-03-10 11:45:15 +01:00
Steffen Jaeckel
b55bf6e4bd Fix some more memory leaks + an invalid read.
`ProfMessage` was not completely initialized, fix this by using `calloc()`
for the allocation.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-10 11:45:15 +01:00
Steffen Jaeckel
93fc4ecd8b Add some more false-positives to our Valgrind suppression list
I hope I didn't overshoot :)

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-10 11:45:15 +01:00
Steffen Jaeckel
c5a131ee46 Introduce our own shutdown callback mechanism.
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>
2025-03-07 21:09:16 +01:00
Steffen Jaeckel
662a0be633 Add --cmd option
This allows to kind of automate what profanity should do as first jobs,
e.g. `--cmd /foo --cmd /bar --cmd /quit` so one can easily check for memory
leaks.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-07 21:09:16 +01:00
Michael Vetter
43bbb16e8e Close file in case of error 2025-03-06 11:19:28 +01:00
Michael Vetter
55a8a26a24 Attempt to open file later to prevent potential resource leak 2025-03-06 11:19:00 +01:00
Michael Vetter
0081db643f Merge pull request #2015 from ventosus/issue#2012
Load resources from chat history db
2025-01-28 17:25:10 +01:00
Michael Vetter
4e06fa4187 Merge pull request #2007 from profanity-im/debug-1946
Debug #1946
2025-01-28 17:21:30 +01:00
Steffen Jaeckel
f27fa98717 Some minor changes
* Fix some linter suggestions.
* Change some defines to `const` vars.
* Free buffer entries in the reverse order they were allocated.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
8151dfa3b4 /quit now exits from the event loop
Before this change issuing `/quit` directly called `exit(0)` and did not
invoke all the graceful shutdown routines. Now we first try to exit from
the event loop, which includes cleaning up everything.
In case the event loop is stuck for some reason, you could try to issue a
second `/quit`, which will then directly call `exit(0)`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
2696989ce5 Fix a bunch of obvious memory leaks at termination
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
06f5c2670e PyEval_InitThreads() is deprecated
`Py_Initialize()` does it since 3.7, it's a noop and deprecated since 3.9.

https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
80193ca41f cmd_ac: Refactor alloc, reset & free
Add all elements to an array, in order to easily be able to run operations
in bulk.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
f67c76c032 Add make target my-prof.supp
This creates a "as personal as possible" Valgrind suppressions file.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
46b788846c These defines don't have to be in the header file
They're only used in `window.c`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
67d8d7110b Revert "Fix underscrolling problem"
This reverts commit d7e46d64fe.
2025-01-28 16:43:13 +01:00
Steffen Jaeckel
69eb852ca5 Provide autogen.sh
This seems to be some kind of standard script name for bootstrapping
autotools.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-01-28 16:43:13 +01:00
Hanspeter Portner
c804137669 Load resources from chat history db
Fixes: https://github.com/profanity-im/profanity/issues/2012
2025-01-26 20:12:41 +01:00
Michael Vetter
329ca8a089 Merge pull request #2014 from ventosus/issue#2013
Make `muc_nick` return a `const char* const`
2025-01-26 18:54:17 +01:00
Hanspeter Portner
cb395b7c09 Make muc_nick return a const char* const
In the documentation of the `muc_nick` function we can read:

> The nickname is owned by the chat room and should not be modified or freed

We should reflect that in the return type and `strdup` the value for the
plugin API.

Fixes: https://github.com/profanity-im/profanity/issues/2013
2025-01-26 18:16:14 +01:00
Michael Vetter
baddf2a8da Merge pull request #2009 from profanity-im/fix/2004-Dockerfile-archlinux-image
Enable Arch CI
2025-01-07 10:33:58 +01:00
Michael Vetter
797e0bc3ce ci: use official libsignal package instead of aur
This fixes the build as well.
2025-01-06 10:17:19 +01:00
Michael Vetter
d7398d11e1 ci: re-enable arch
This reverts commit 3def839c0e.
2025-01-05 18:39:58 +01:00
belmiro adriano
bbc88557a4 ci: replace archlinux tag in Dockerfile
This pull request addresses an error in the Dockerfile.arch file caused by using an incorrect base image reference (archlinux/latest). The Docker Hub archlinux repository does not support a latest tag, which leads to a "failed to resolve source metadata" error during the Docker build process. This PR updates the base image reference to archlinux, resolving the error and allowing for a successful build.

Fix https://github.com/profanity-im/profanity/issues/2004

Note: Commit message edited by @jubalh since @tjsweetblack didn't respond.
2025-01-05 18:34:25 +01:00
Michael Vetter
313ab5d55a Merge pull request #1998 from mdosch/no-plenking
Remove plenking
2024-10-04 11:57:56 +02:00
Martin Dosch
50e82376b0 Remove plenking
There were two cases of plenking (a space between a word and the punctuation
marks) in front of `…`.
2024-10-03 15:51:52 +02:00
Michael Vetter
dce0b7376e Add cosmetic commit to ignore file 2024-09-19 08:35:09 +02:00
Michael Vetter
69301503ce Add missing space to description 2024-09-19 08:34:21 +02:00
Michael Vetter
0995b1a180 Add NULL check to _gpgme_key_to_ProfPGPKey
Fix https://github.com/profanity-im/profanity/issues/1995

Tested-by: Martin Dosch <martin@mdosch.de>
2024-09-07 12:44:42 +02:00
Michael Vetter
3b19a6afcd Merge pull request #1993 from profanity-im/fix/1992-typemismatch
Fix outdated types in tests
2024-08-05 17:17:52 +02:00
Michael Vetter
3441aa3279 Fix outdated types in tests
Fix https://github.com/profanity-im/profanity/issues/1992
2024-08-05 12:14:09 +02:00
Michael Vetter
beeddda568 docs: Add more info to ignore revs 2024-06-24 10:24:40 +02:00