mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 13:26:21 +00:00
fix(mam, log): improve datetime handling and memory management in MAM and log fetching
- Introduce static helper `_truncate_datetime_suffix()` to safely trim datetime strings, removing unwanted suffixes like timezone offsets - Replace manual string management with auto_gchar and g_strdup for safer, clearer ownership and to prevent leaks - Add safety checks and logging warnings for unexpected datetime string lengths or null pointers - Refactor _mam_rsm_id_handler to use the helper function and updated string handling - Change log_database_get_previous_chat parameters for consistent ownership semantics, avoiding double frees and mem leaks - Overall improve stability and prevent memory leaks during log database queries
This commit is contained in:
@@ -711,19 +711,17 @@ win_page_down(ProfWin* window, int scroll_size)
|
||||
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
|
||||
int bf_size = buffer_size(window->layout->buffer);
|
||||
if (bf_size > 0) {
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1);
|
||||
auto_gchar gchar* start = g_date_time_format_iso8601(last_entry->time);
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
gchar* end_date = g_date_time_format_iso8601(now);
|
||||
g_date_time_unref(now);
|
||||
auto_gchar gchar* end_date = g_date_time_format_iso8601(now);
|
||||
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;
|
||||
*page_start = offset - page_space + scroll_size;
|
||||
g_date_time_unref(now);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user