mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
fix more memory leaks
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
parent
698aefa005
commit
e886ba0c6f
@ -2849,7 +2849,7 @@ _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
|||||||
gboolean result;
|
gboolean result;
|
||||||
gchar** args = parse_args(input, 2, 3, &result);
|
gchar** args = parse_args(input, 2, 3, &result);
|
||||||
if (result) {
|
if (result) {
|
||||||
gchar* jid = g_strdup(args[1]);
|
auto_gchar gchar* jid = g_strdup(args[1]);
|
||||||
found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous, jid);
|
found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous, jid);
|
||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
@ -2876,7 +2876,7 @@ _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
|||||||
gboolean result;
|
gboolean result;
|
||||||
gchar** args = parse_args(input, 2, 3, &result);
|
gchar** args = parse_args(input, 2, 3, &result);
|
||||||
if (result) {
|
if (result) {
|
||||||
gchar* jid = g_strdup(args[1]);
|
auto_gchar gchar* jid = g_strdup(args[1]);
|
||||||
found = autocomplete_param_no_with_func(input, "/omemo untrust", 4, omemo_fingerprint_autocomplete, previous, jid);
|
found = autocomplete_param_no_with_func(input, "/omemo untrust", 4, omemo_fingerprint_autocomplete, previous, jid);
|
||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
|
@ -8436,18 +8436,19 @@ _cmd_execute(ProfWin* window, const char* const command, const char* const inp)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
while (cmd->sub_funcs[i].cmd) {
|
while (cmd->sub_funcs[i].cmd) {
|
||||||
if (g_strcmp0(args[0], (char*)cmd->sub_funcs[i].cmd) == 0) {
|
if (g_strcmp0(args[0], (char*)cmd->sub_funcs[i].cmd) == 0) {
|
||||||
gboolean result = cmd->sub_funcs[i].func(window, command, args);
|
result = cmd->sub_funcs[i].func(window, command, args);
|
||||||
g_strfreev(args);
|
goto out;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!cmd->func) {
|
if (!cmd->func) {
|
||||||
ui_invalid_command_usage(cmd->cmd, cmd->setting_func);
|
ui_invalid_command_usage(cmd->cmd, cmd->setting_func);
|
||||||
return TRUE;
|
result = TRUE;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
gboolean result = cmd->func(window, command, args);
|
result = cmd->func(window, command, args);
|
||||||
|
out:
|
||||||
g_strfreev(args);
|
g_strfreev(args);
|
||||||
return result;
|
return result;
|
||||||
} else if (plugins_run_command(inp)) {
|
} else if (plugins_run_command(inp)) {
|
||||||
@ -8887,6 +8888,7 @@ cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args)
|
|||||||
free(formatted_fingerprint);
|
free(formatted_fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jid_destroy(jid);
|
||||||
g_list_free(fingerprints);
|
g_list_free(fingerprints);
|
||||||
|
|
||||||
win_println(window, THEME_DEFAULT, "-", "You can trust it with '/omemo trust <fingerprint>'");
|
win_println(window, THEME_DEFAULT, "-", "You can trust it with '/omemo trust <fingerprint>'");
|
||||||
|
@ -57,6 +57,16 @@ static char* _get_db_filename(ProfAccount* account);
|
|||||||
static prof_msg_type_t _get_message_type_type(const char* const type);
|
static prof_msg_type_t _get_message_type_type(const char* const type);
|
||||||
static prof_enc_t _get_message_enc_type(const char* const encstr);
|
static prof_enc_t _get_message_enc_type(const char* const encstr);
|
||||||
|
|
||||||
|
#define auto_sqlite __attribute__((__cleanup__(auto_free_sqlite)))
|
||||||
|
|
||||||
|
static void
|
||||||
|
auto_free_sqlite(gchar** str)
|
||||||
|
{
|
||||||
|
if (str == NULL)
|
||||||
|
return;
|
||||||
|
sqlite3_free(*str);
|
||||||
|
}
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
_get_db_filename(ProfAccount* account)
|
_get_db_filename(ProfAccount* account)
|
||||||
{
|
{
|
||||||
@ -243,7 +253,6 @@ GSList*
|
|||||||
log_database_get_previous_chat(const gchar* const contact_barejid, char* start_time, char* end_time, gboolean from_start, gboolean flip)
|
log_database_get_previous_chat(const gchar* const contact_barejid, char* start_time, char* end_time, gboolean from_start, gboolean flip)
|
||||||
{
|
{
|
||||||
sqlite3_stmt* stmt = NULL;
|
sqlite3_stmt* stmt = NULL;
|
||||||
gchar* query;
|
|
||||||
const char* jid = connection_get_fulljid();
|
const char* jid = connection_get_fulljid();
|
||||||
Jid* myjid = jid_create(jid);
|
Jid* myjid = jid_create(jid);
|
||||||
if (!myjid)
|
if (!myjid)
|
||||||
@ -254,7 +263,7 @@ log_database_get_previous_chat(const gchar* const contact_barejid, char* start_t
|
|||||||
gchar* sort2 = !flip ? "ASC" : "DESC";
|
gchar* sort2 = !flip ? "ASC" : "DESC";
|
||||||
GDateTime* now = g_date_time_new_now_local();
|
GDateTime* now = g_date_time_new_now_local();
|
||||||
gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
|
gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
|
||||||
query = sqlite3_mprintf("SELECT * FROM (SELECT COALESCE(B.`message`, A.`message`) AS message, A.`timestamp`, A.`from_jid`, A.`type`, A.`encryption` from `ChatLogs` AS A LEFT JOIN `ChatLogs` AS B ON A.`stanza_id` = B.`replace_id` WHERE A.`replace_id` = '' AND ((A.`from_jid` = '%q' AND A.`to_jid` = '%q') OR (A.`from_jid` = '%q' AND A.`to_jid` = '%q')) AND A.`timestamp` < '%q' AND (%Q IS NULL OR A.`timestamp` > %Q) ORDER BY A.`timestamp` %s LIMIT %d) ORDER BY `timestamp` %s;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid, end_date_fmt, start_time, start_time, sort1, MESSAGES_TO_RETRIEVE, sort2);
|
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM (SELECT COALESCE(B.`message`, A.`message`) AS message, A.`timestamp`, A.`from_jid`, A.`type`, A.`encryption` from `ChatLogs` AS A LEFT JOIN `ChatLogs` AS B ON A.`stanza_id` = B.`replace_id` WHERE A.`replace_id` = '' AND ((A.`from_jid` = '%q' AND A.`to_jid` = '%q') OR (A.`from_jid` = '%q' AND A.`to_jid` = '%q')) AND A.`timestamp` < '%q' AND (%Q IS NULL OR A.`timestamp` > %Q) ORDER BY A.`timestamp` %s LIMIT %d) ORDER BY `timestamp` %s;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid, end_date_fmt, start_time, start_time, sort1, MESSAGES_TO_RETRIEVE, sort2);
|
||||||
|
|
||||||
g_date_time_unref(now);
|
g_date_time_unref(now);
|
||||||
g_free(end_date_fmt);
|
g_free(end_date_fmt);
|
||||||
@ -292,7 +301,6 @@ log_database_get_previous_chat(const gchar* const contact_barejid, char* start_t
|
|||||||
history = g_slist_append(history, msg);
|
history = g_slist_append(history, msg);
|
||||||
}
|
}
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
sqlite3_free(query);
|
|
||||||
|
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ get_message_from_editor(gchar* message, gchar** returned_message)
|
|||||||
|
|
||||||
gchar* filename = NULL;
|
gchar* filename = NULL;
|
||||||
GError* glib_error = NULL;
|
GError* glib_error = NULL;
|
||||||
char* jid = connection_get_barejid();
|
auto_char char* jid = connection_get_barejid();
|
||||||
if (jid) {
|
if (jid) {
|
||||||
filename = files_file_in_account_data_path(DIR_EDITOR, jid, "compose.md");
|
filename = files_file_in_account_data_path(DIR_EDITOR, jid, "compose.md");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1470,7 +1470,7 @@ win_print_outgoing(ProfWin* window, const char* show_char, const char* const id,
|
|||||||
if (replace_id) {
|
if (replace_id) {
|
||||||
_win_correct(window, message, id, replace_id, myjid);
|
_win_correct(window, message, id, replace_id, myjid);
|
||||||
} else {
|
} else {
|
||||||
char* outgoing_str = prefs_get_string(PREF_OUTGOING_STAMP);
|
auto_char gchar* outgoing_str = prefs_get_string(PREF_OUTGOING_STAMP);
|
||||||
_win_printf(window, show_char, 0, timestamp, 0, THEME_TEXT_ME, outgoing_str, myjid, id, "%s", message);
|
_win_printf(window, show_char, 0, timestamp, 0, THEME_TEXT_ME, outgoing_str, myjid, id, "%s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2187,6 +2187,7 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
|
|||||||
identity->name = strdup(name);
|
identity->name = strdup(name);
|
||||||
ProfMucWin* mucwin = wins_get_muc(cb_data->room);
|
ProfMucWin* mucwin = wins_get_muc(cb_data->room);
|
||||||
if (mucwin) {
|
if (mucwin) {
|
||||||
|
free(mucwin->room_name);
|
||||||
mucwin->room_name = strdup(name);
|
mucwin->room_name = strdup(name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2607,6 +2608,8 @@ _mam_buffer_commit_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const gchar* mam_timestamp_format_string = "%FT%T.%f%:z";
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_mam_request_older(ProfChatWin* win)
|
iq_mam_request_older(ProfChatWin* win)
|
||||||
{
|
{
|
||||||
@ -2623,7 +2626,7 @@ iq_mam_request_older(ProfChatWin* win)
|
|||||||
// If first message found
|
// If first message found
|
||||||
if (first_msg->timestamp) {
|
if (first_msg->timestamp) {
|
||||||
firstid = first_msg->stanzaid;
|
firstid = first_msg->stanzaid;
|
||||||
enddate = g_date_time_format(first_msg->timestamp, "%FT%T.%f%:z");
|
enddate = g_date_time_format(first_msg->timestamp, mam_timestamp_format_string);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2647,6 +2650,8 @@ _iq_mam_request(ProfChatWin* win, GDateTime* startdate, GDateTime* enddate)
|
|||||||
if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
|
if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
|
||||||
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2);
|
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2);
|
||||||
cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2);
|
cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2);
|
||||||
|
g_date_time_unref(startdate);
|
||||||
|
g_date_time_unref(enddate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2656,18 +2661,18 @@ _iq_mam_request(ProfChatWin* win, GDateTime* startdate, GDateTime* enddate)
|
|||||||
gboolean fetch_next = FALSE;
|
gboolean fetch_next = FALSE;
|
||||||
|
|
||||||
if (startdate) {
|
if (startdate) {
|
||||||
startdate_str = g_date_time_format(startdate, "%FT%T.%f%:z");
|
startdate_str = g_date_time_format(startdate, mam_timestamp_format_string);
|
||||||
fetch_next = TRUE;
|
fetch_next = TRUE;
|
||||||
g_date_time_unref(startdate);
|
g_date_time_unref(startdate);
|
||||||
} else if (!enddate) {
|
|
||||||
GDateTime* now = g_date_time_new_now_utc();
|
|
||||||
enddate_str = g_date_time_format(now, "%FT%T.%f%:z");
|
|
||||||
g_date_time_unref(now);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enddate) {
|
if (enddate) {
|
||||||
enddate_str = g_date_time_format(enddate, "%FT%T.%f%:z");
|
enddate_str = g_date_time_format(enddate, mam_timestamp_format_string);
|
||||||
g_date_time_unref(enddate);
|
g_date_time_unref(enddate);
|
||||||
|
} else {
|
||||||
|
GDateTime* now = g_date_time_new_now_utc();
|
||||||
|
enddate_str = g_date_time_format(now, mam_timestamp_format_string);
|
||||||
|
g_date_time_unref(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||||
@ -2695,15 +2700,15 @@ void
|
|||||||
iq_mam_request(ProfChatWin* win, GDateTime* enddate)
|
iq_mam_request(ProfChatWin* win, GDateTime* enddate)
|
||||||
{
|
{
|
||||||
ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE);
|
ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE);
|
||||||
GDateTime* startdate = last_msg->timestamp ? g_date_time_add_seconds(last_msg->timestamp, 0) : NULL; // copy timestamp
|
GDateTime* startdate = g_date_time_add_seconds(last_msg->timestamp, 0);
|
||||||
message_free(last_msg);
|
message_free(last_msg);
|
||||||
|
|
||||||
// Save request for later if disco items haven't been received yet
|
// Save request for later if disco items haven't been received yet
|
||||||
if (!received_disco_items) {
|
if (!received_disco_items) {
|
||||||
LateDeliveryUserdata* cur_del_data = malloc(sizeof(LateDeliveryUserdata));
|
LateDeliveryUserdata* cur_del_data = malloc(sizeof(LateDeliveryUserdata));
|
||||||
cur_del_data->win = win;
|
cur_del_data->win = win;
|
||||||
cur_del_data->enddate = enddate;
|
cur_del_data->enddate = g_date_time_ref(enddate);
|
||||||
cur_del_data->startdate = startdate;
|
cur_del_data->startdate = g_date_time_ref(startdate);
|
||||||
late_delivery_windows = g_slist_append(late_delivery_windows, cur_del_data);
|
late_delivery_windows = g_slist_append(late_delivery_windows, cur_del_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ _receive_mood(xmpp_stanza_t* const stanza, void* const userdata)
|
|||||||
const char* m = xmpp_stanza_get_name(c);
|
const char* m = xmpp_stanza_get_name(c);
|
||||||
xmpp_stanza_t* t = xmpp_stanza_get_child_by_name(mood, STANZA_NAME_TEXT);
|
xmpp_stanza_t* t = xmpp_stanza_get_child_by_name(mood, STANZA_NAME_TEXT);
|
||||||
if (t) {
|
if (t) {
|
||||||
const char* text = xmpp_stanza_get_text(t);
|
auto_char char* text = xmpp_stanza_get_text(t);
|
||||||
cons_show("Mood from %s %s (%s)", from, m, text);
|
cons_show("Mood from %s %s (%s)", from, m, text);
|
||||||
} else {
|
} else {
|
||||||
cons_show("Mood from %s %s", from, m);
|
cons_show("Mood from %s %s", from, m);
|
||||||
|
Loading…
Reference in New Issue
Block a user