Fix potential double free.

Change `log_database_get_previous_chat()` to not take ownership of
`end_time`, so it's clear that whoever passes it in, has to free it.

Fixes: https://github.com/profanity-im/profanity/issues/2110
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2026-03-18 13:05:14 +01:00
parent 349de02b8c
commit 2240879956
5 changed files with 9 additions and 10 deletions

View File

@@ -682,11 +682,9 @@ win_page_down(ProfWin* window, int scroll_size)
if (bf_size != 0) {
ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1);
auto_gchar gchar* start = g_date_time_format_iso8601(last_entry->time);
gchar* end_date = prof_date_time_format_iso8601(NULL);
auto_gchar gchar* end_date = prof_date_time_format_iso8601(NULL);
if (*scroll_state != WIN_SCROLL_REACHED_BOTTOM && !chatwin_db_history((ProfChatWin*)window, start, end_date, FALSE)) {
*scroll_state = WIN_SCROLL_REACHED_BOTTOM;
} else if (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) {
g_free(end_date);
}
int offset = last_entry->y_end_pos - 1;