mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 06:26:20 +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:
@@ -40,6 +40,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "glib.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "window_list.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
@@ -585,10 +586,12 @@ _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
|
||||
// first entry's timestamp in the buffer is used. Flip true to prepend to buffer.
|
||||
// Timestamps should be in iso8601
|
||||
db_history_result_t
|
||||
chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip)
|
||||
chatwin_db_history(ProfChatWin* chatwin, const gchar* start_time, const gchar* end_time, gboolean flip)
|
||||
{
|
||||
if (!end_time) {
|
||||
end_time = buffer_size(((ProfWin*)chatwin)->layout->buffer) == 0 ? NULL : g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
|
||||
auto_gchar gchar* _end_time = NULL;
|
||||
if (!end_time && buffer_size(((ProfWin*)chatwin)->layout->buffer) > 0) {
|
||||
_end_time = g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
|
||||
end_time = _end_time;
|
||||
}
|
||||
|
||||
GSList* history = NULL;
|
||||
|
||||
Reference in New Issue
Block a user