1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge pull request #1863 from H3rnand3zzz/cleanup/auto_char_part1

Change `char`->`free` to `auto_char char` for autocleanup
This commit is contained in:
Michael Vetter 2023-07-12 13:51:43 +02:00 committed by GitHub
commit 91c2c5f374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 514 additions and 969 deletions

View File

@ -85,9 +85,8 @@ void
chat_log_msg_out(const char* const barejid, const char* const msg, const char* const resource) chat_log_msg_out(const char* const barejid, const char* const msg, const char* const resource)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
free(mybarejid);
} }
} }
@ -95,14 +94,13 @@ void
chat_log_otr_msg_out(const char* const barejid, const char* const msg, const char* const resource) chat_log_otr_msg_out(const char* const barejid, const char* const msg, const char* const resource)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_otr_log = prefs_get_string(PREF_OTR_LOG); auto_gchar gchar* pref_otr_log = prefs_get_string(PREF_OTR_LOG);
if (strcmp(pref_otr_log, "on") == 0) { if (strcmp(pref_otr_log, "on") == 0) {
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
} else if (strcmp(pref_otr_log, "redact") == 0) { } else if (strcmp(pref_otr_log, "redact") == 0) {
_chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
} }
free(mybarejid);
} }
} }
@ -110,14 +108,13 @@ void
chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const char* const resource) chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const char* const resource)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_pgp_log = prefs_get_string(PREF_PGP_LOG); auto_gchar gchar* pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
if (strcmp(pref_pgp_log, "on") == 0) { if (strcmp(pref_pgp_log, "on") == 0) {
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
} else if (strcmp(pref_pgp_log, "redact") == 0) { } else if (strcmp(pref_pgp_log, "redact") == 0) {
_chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
} }
free(mybarejid);
} }
} }
@ -125,14 +122,13 @@ void
chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const char* const resource) chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const char* const resource)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
if (strcmp(pref_omemo_log, "on") == 0) { if (strcmp(pref_omemo_log, "on") == 0) {
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
} else if (strcmp(pref_omemo_log, "redact") == 0) { } else if (strcmp(pref_omemo_log, "redact") == 0) {
_chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); _chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
} }
free(mybarejid);
} }
} }
@ -140,7 +136,7 @@ void
chat_log_otr_msg_in(ProfMessage* message) chat_log_otr_msg_in(ProfMessage* message)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_otr_log = prefs_get_string(PREF_OTR_LOG); auto_gchar gchar* pref_otr_log = prefs_get_string(PREF_OTR_LOG);
if (message->enc == PROF_MSG_ENC_NONE || (strcmp(pref_otr_log, "on") == 0)) { if (message->enc == PROF_MSG_ENC_NONE || (strcmp(pref_otr_log, "on") == 0)) {
if (message->type == PROF_MSG_TYPE_MUCPM) { if (message->type == PROF_MSG_TYPE_MUCPM) {
@ -155,7 +151,6 @@ chat_log_otr_msg_in(ProfMessage* message)
_chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL);
} }
} }
free(mybarejid);
} }
} }
@ -163,7 +158,7 @@ void
chat_log_pgp_msg_in(ProfMessage* message) chat_log_pgp_msg_in(ProfMessage* message)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_pgp_log = prefs_get_string(PREF_PGP_LOG); auto_gchar gchar* pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
if (strcmp(pref_pgp_log, "on") == 0) { if (strcmp(pref_pgp_log, "on") == 0) {
if (message->type == PROF_MSG_TYPE_MUCPM) { if (message->type == PROF_MSG_TYPE_MUCPM) {
@ -178,7 +173,6 @@ chat_log_pgp_msg_in(ProfMessage* message)
_chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL);
} }
} }
free(mybarejid);
} }
} }
@ -186,7 +180,7 @@ void
chat_log_omemo_msg_in(ProfMessage* message) chat_log_omemo_msg_in(ProfMessage* message)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
if (strcmp(pref_omemo_log, "on") == 0) { if (strcmp(pref_omemo_log, "on") == 0) {
if (message->type == PROF_MSG_TYPE_MUCPM) { if (message->type == PROF_MSG_TYPE_MUCPM) {
@ -201,7 +195,6 @@ chat_log_omemo_msg_in(ProfMessage* message)
_chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart);
} }
} }
free(mybarejid);
} }
} }
@ -209,15 +202,13 @@ void
chat_log_msg_in(ProfMessage* message) chat_log_msg_in(ProfMessage* message)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
if (message->type == PROF_MSG_TYPE_MUCPM) { if (message->type == PROF_MSG_TYPE_MUCPM) {
_chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart);
} else { } else {
_chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL);
} }
free(mybarejid);
} }
} }
@ -317,10 +308,9 @@ void
groupchat_log_msg_out(const gchar* const room, const gchar* const msg) groupchat_log_msg_out(const gchar* const room, const gchar* const msg)
{ {
if (prefs_get_boolean(PREF_GRLOG)) { if (prefs_get_boolean(PREF_GRLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
char* mynick = muc_nick(room); char* mynick = muc_nick(room);
_groupchat_log_chat(mybarejid, room, mynick, msg); _groupchat_log_chat(mybarejid, room, mynick, msg);
free(mybarejid);
} }
} }
@ -328,9 +318,8 @@ void
groupchat_log_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) groupchat_log_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg)
{ {
if (prefs_get_boolean(PREF_GRLOG)) { if (prefs_get_boolean(PREF_GRLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
_groupchat_log_chat(mybarejid, room, nick, msg); _groupchat_log_chat(mybarejid, room, nick, msg);
free(mybarejid);
} }
} }
@ -338,7 +327,7 @@ void
groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg) groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg)
{ {
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
char* mynick = muc_nick(room); char* mynick = muc_nick(room);
@ -347,8 +336,6 @@ groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg)
} else if (strcmp(pref_omemo_log, "redact") == 0) { } else if (strcmp(pref_omemo_log, "redact") == 0) {
_groupchat_log_chat(mybarejid, room, mynick, "[redacted]"); _groupchat_log_chat(mybarejid, room, mynick, "[redacted]");
} }
free(mybarejid);
} }
} }
@ -434,14 +421,12 @@ static struct dated_chat_log*
_create_chatlog(const char* const other, const char* const login) _create_chatlog(const char* const other, const char* const login)
{ {
GDateTime* now = g_date_time_new_now_local(); GDateTime* now = g_date_time_new_now_local();
char* filename = _get_log_filename(other, login, now, FALSE); auto_char char* filename = _get_log_filename(other, login, now, FALSE);
struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log)); struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log));
new_log->filename = strdup(filename); new_log->filename = strdup(filename);
new_log->date = now; new_log->date = now;
free(filename);
return new_log; return new_log;
} }
@ -449,14 +434,12 @@ static struct dated_chat_log*
_create_groupchat_log(const char* const room, const char* const login) _create_groupchat_log(const char* const room, const char* const login)
{ {
GDateTime* now = g_date_time_new_now_local(); GDateTime* now = g_date_time_new_now_local();
char* filename = _get_log_filename(room, login, now, TRUE); auto_char char* filename = _get_log_filename(room, login, now, TRUE);
struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log)); struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log));
new_log->filename = strdup(filename); new_log->filename = strdup(filename);
new_log->date = now; new_log->date = now;
free(filename);
return new_log; return new_log;
} }

View File

@ -3052,13 +3052,12 @@ command_mangen(void)
while (curr) { while (curr) {
Command* pcmd = curr->data; Command* pcmd = curr->data;
gchar* filename = g_strdup_printf("docs/profanity-%s.1", &pcmd->cmd[1]); auto_gchar gchar* filename = g_strdup_printf("docs/profanity-%s.1", &pcmd->cmd[1]);
if (!filename) { if (!filename) {
log_error("command_mangen(): could not allocate memory"); log_error("command_mangen(): could not allocate memory");
return; return;
} }
FILE* manpage = fopen(filename, "w"); FILE* manpage = fopen(filename, "w");
free(filename);
fprintf(manpage, "%s\n", header); fprintf(manpage, "%s\n", header);
fputs(".SH NAME\n", manpage); fputs(".SH NAME\n", manpage);

File diff suppressed because it is too large Load Diff

View File

@ -143,11 +143,10 @@ str_replace(const char* string, const char* substr,
head = newstr; head = newstr;
while ((tok = strstr(head, substr))) { while ((tok = strstr(head, substr))) {
char* oldstr = newstr; auto_char char* oldstr = newstr;
newstr = malloc(strlen(oldstr) - strlen(substr) + strlen(replacement) + 1); newstr = malloc(strlen(oldstr) - strlen(substr) + strlen(replacement) + 1);
if (newstr == NULL) { if (newstr == NULL) {
free(oldstr);
return NULL; return NULL;
} }
@ -159,7 +158,6 @@ str_replace(const char* string, const char* substr,
memset(newstr + strlen(oldstr) - strlen(substr) + strlen(replacement), 0, 1); memset(newstr + strlen(oldstr) - strlen(substr) + strlen(replacement), 0, 1);
head = newstr + (tok - oldstr) + strlen(replacement); head = newstr + (tok - oldstr) + strlen(replacement);
free(oldstr);
} }
return newstr; return newstr;
@ -282,10 +280,10 @@ _data_callback(void* ptr, size_t size, size_t nmemb, void* data)
return realsize; return realsize;
} }
char* gchar*
get_file_or_linked(char* loc, char* basedir) get_file_or_linked(gchar* loc, gchar* basedir)
{ {
char* true_loc = NULL; gchar* true_loc = NULL;
// check for symlink // check for symlink
if (g_file_test(loc, G_FILE_TEST_IS_SYMLINK)) { if (g_file_test(loc, G_FILE_TEST_IS_SYMLINK)) {
@ -293,13 +291,13 @@ get_file_or_linked(char* loc, char* basedir)
// if relative, add basedir // if relative, add basedir
if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) { if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) {
char* tmp = g_strdup_printf("%s/%s", basedir, true_loc); gchar* tmp = g_strdup_printf("%s/%s", basedir, true_loc);
free(true_loc); g_free(true_loc);
true_loc = tmp; true_loc = tmp;
} }
// use given location // use given location
} else { } else {
true_loc = strdup(loc); true_loc = g_strdup(loc);
} }
return true_loc; return true_loc;

View File

@ -110,7 +110,7 @@ int utf8_display_len(const char* const str);
char* release_get_latest(void); char* release_get_latest(void);
gboolean release_is_new(char* found_version); gboolean release_is_new(char* found_version);
char* get_file_or_linked(char* loc, char* basedir); gchar* get_file_or_linked(gchar* loc, gchar* basedir);
char* strip_arg_quotes(const char* const input); char* strip_arg_quotes(const char* const input);
gboolean is_notify_enabled(void); gboolean is_notify_enabled(void);

View File

@ -53,7 +53,7 @@
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#include "xmpp/jid.h" #include "xmpp/jid.h"
static char* accounts_loc; static gchar* accounts_loc;
static GKeyFile* accounts; static GKeyFile* accounts;
static Autocomplete all_ac; static Autocomplete all_ac;
@ -861,9 +861,8 @@ accounts_set_last_activity(const char* const account_name)
g_date_time_unref(nowdt); g_date_time_unref(nowdt);
if (res) { if (res) {
char* timestr = g_time_val_to_iso8601(&nowtv); auto_char char* timestr = g_time_val_to_iso8601(&nowtv);
g_key_file_set_string(accounts, account_name, "last.activity", timestr); g_key_file_set_string(accounts, account_name, "last.activity", timestr);
free(timestr);
_save_accounts(); _save_accounts();
} }
} }
@ -942,7 +941,7 @@ resource_presence_t
accounts_get_login_presence(const char* const account_name) accounts_get_login_presence(const char* const account_name)
{ {
resource_presence_t result; resource_presence_t result;
gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL); auto_gchar gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
if (setting == NULL || (strcmp(setting, "online") == 0)) { if (setting == NULL || (strcmp(setting, "online") == 0)) {
result = RESOURCE_ONLINE; result = RESOURCE_ONLINE;
@ -961,21 +960,19 @@ accounts_get_login_presence(const char* const account_name)
result = RESOURCE_ONLINE; result = RESOURCE_ONLINE;
} }
g_free(setting);
return result; return result;
} }
char* char*
accounts_get_login_status(const char* const account_name) accounts_get_login_status(const char* const account_name)
{ {
gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL); auto_gchar gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
gchar* status = NULL; gchar* status = NULL;
if (g_strcmp0(setting, "last") == 0) { if (g_strcmp0(setting, "last") == 0) {
status = accounts_get_last_status(account_name); status = accounts_get_last_status(account_name);
} }
g_free(setting);
return status; return status;
} }
@ -983,14 +980,10 @@ static void
_save_accounts(void) _save_accounts(void)
{ {
gsize g_data_size; gsize g_data_size;
gchar* g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL); auto_gchar gchar* g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
gchar* base = g_path_get_dirname(accounts_loc); auto_gchar gchar* base = g_path_get_dirname(accounts_loc);
gchar* true_loc = get_file_or_linked(accounts_loc, base); auto_gchar gchar* true_loc = get_file_or_linked(accounts_loc, base);
g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);
g_chmod(accounts_loc, S_IRUSR | S_IWUSR); g_chmod(accounts_loc, S_IRUSR | S_IWUSR);
g_free(base);
free(true_loc);
g_free(g_accounts_data);
} }

View File

@ -49,13 +49,11 @@
static gchar* static gchar*
_cafile_name(void) _cafile_name(void)
{ {
gchar* certs_dir = files_get_data_path(DIR_CERTS); auto_gchar gchar* certs_dir = files_get_data_path(DIR_CERTS);
if (!create_dir(certs_dir)) { if (!create_dir(certs_dir)) {
g_free(certs_dir);
return NULL; return NULL;
} }
gchar* filename = g_strdup_printf("%s/CAfile.pem", certs_dir); gchar* filename = g_strdup_printf("%s/CAfile.pem", certs_dir);
g_free(certs_dir);
return filename; return filename;
} }

View File

@ -35,6 +35,7 @@
*/ */
#include "config.h" #include "config.h"
#include "common.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -508,10 +509,9 @@ color_pair_cache_hash_str(const char* str, color_profile profile)
int fg = color_hash(str, profile); int fg = color_hash(str, profile);
int bg = -1; int bg = -1;
char* bkgnd = theme_get_bkgnd(); auto_char char* bkgnd = theme_get_bkgnd();
if (bkgnd) { if (bkgnd) {
bg = find_col(bkgnd, strlen(bkgnd)); bg = find_col(bkgnd, strlen(bkgnd));
free(bkgnd);
} }
return _color_pair_cache_get(fg, bg); return _color_pair_cache_get(fg, bg);

View File

@ -117,7 +117,7 @@ files_get_inputrc_file(void)
gchar* gchar*
files_get_log_file(const char* const log_file) files_get_log_file(const char* const log_file)
{ {
gchar* xdg_data = _files_get_xdg_data_home(); auto_gchar gchar* xdg_data = _files_get_xdg_data_home();
GString* logfile; GString* logfile;
if (log_file) { if (log_file) {
@ -141,7 +141,6 @@ files_get_log_file(const char* const log_file)
gchar* result = g_strdup(logfile->str); gchar* result = g_strdup(logfile->str);
free(xdg_data);
g_string_free(logfile, TRUE); g_string_free(logfile, TRUE);
return result; return result;
@ -156,27 +155,30 @@ files_get_config_path(const char* const config_base)
return result; return result;
} }
/**
* Get the full path by appending the given location to the project base path.
*
* @param location The location (directory or file) to append to the project base path.
* @return The full path obtained by appending the location to the project base path.
*
* @note The returned value must be freed using g_free when it is no longer needed
* to prevent memory leaks.
*/
gchar* gchar*
files_get_data_path(const char* const data_base) files_get_data_path(const char* const location)
{ {
gchar* xdg_data = _files_get_xdg_data_home(); auto_gchar gchar* xdg_data = _files_get_xdg_data_home();
gchar* result = g_strdup_printf("%s/profanity/%s", xdg_data, data_base); gchar* result = g_strdup_printf("%s/profanity/%s", xdg_data, location);
g_free(xdg_data);
return result; return result;
} }
gchar* gchar*
files_get_account_data_path(const char* const specific_dir, const char* const jid) files_get_account_data_path(const char* const specific_dir, const char* const jid)
{ {
gchar* data_dir = files_get_data_path(specific_dir); auto_gchar gchar* data_dir = files_get_data_path(specific_dir);
gchar* account_dir = str_replace(jid, "@", "_at_"); auto_gchar gchar* account_dir = str_replace(jid, "@", "_at_");
gchar* result = g_strdup_printf("%s/%s", data_dir, account_dir); return g_strdup_printf("%s/%s", data_dir, account_dir);
g_free(account_dir);
g_free(data_dir);
return result;
} }
gchar* gchar*

View File

@ -65,7 +65,7 @@
void files_create_directories(void); void files_create_directories(void);
gchar* files_get_config_path(const char* const config_base); gchar* files_get_config_path(const char* const config_base);
gchar* files_get_data_path(const char* const data_base); gchar* files_get_data_path(const char* const location);
gchar* files_get_account_data_path(const char* const specific_dir, const char* const jid); gchar* files_get_account_data_path(const char* const specific_dir, const char* const jid);
gchar* files_get_log_file(const char* const log_file); gchar* files_get_log_file(const char* const log_file);

View File

@ -288,7 +288,7 @@ prefs_close(void)
prefs_loc = NULL; prefs_loc = NULL;
} }
char* gchar*
prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context) prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context)
{ {
return autocomplete_complete(boolean_choice_ac, prefix, TRUE, previous); return autocomplete_complete(boolean_choice_ac, prefix, TRUE, previous);
@ -300,7 +300,7 @@ prefs_reset_boolean_choice(void)
autocomplete_reset(boolean_choice_ac); autocomplete_reset(boolean_choice_ac);
} }
char* gchar*
prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context) prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context)
{ {
return autocomplete_complete(room_trigger_ac, prefix, TRUE, previous); return autocomplete_complete(room_trigger_ac, prefix, TRUE, previous);
@ -1631,7 +1631,7 @@ prefs_add_alias(const char* const name, const char* const value)
} }
} }
char* gchar*
prefs_get_alias(const char* const name) prefs_get_alias(const char* const name)
{ {
return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL); return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
@ -1704,16 +1704,12 @@ static void
_save_prefs(void) _save_prefs(void)
{ {
gsize g_data_size; gsize g_data_size;
gchar* g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); auto_gchar gchar* g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
gchar* base = g_path_get_dirname(prefs_loc); auto_gchar gchar* base = g_path_get_dirname(prefs_loc);
gchar* true_loc = get_file_or_linked(prefs_loc, base); auto_gchar gchar* true_loc = get_file_or_linked(prefs_loc, base);
g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL); g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL);
g_chmod(prefs_loc, S_IRUSR | S_IWUSR); g_chmod(prefs_loc, S_IRUSR | S_IWUSR);
g_free(base);
free(true_loc);
g_free(g_prefs_data);
} }
// get the preference group for a specific preference // get the preference group for a specific preference

View File

@ -213,10 +213,10 @@ void prefs_reload(void);
char* prefs_find_login(char* prefix); char* prefs_find_login(char* prefix);
void prefs_reset_login_search(void); void prefs_reset_login_search(void);
char* prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context); gchar* prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context);
void prefs_reset_boolean_choice(void); void prefs_reset_boolean_choice(void);
char* prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context); gchar* prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context);
void prefs_reset_room_trigger_ac(void); void prefs_reset_room_trigger_ac(void);
gint prefs_get_gone(void); gint prefs_get_gone(void);
@ -311,7 +311,7 @@ gint prefs_get_tray_timer(void);
gboolean prefs_add_alias(const char* const name, const char* const value); gboolean prefs_add_alias(const char* const name, const char* const value);
gboolean prefs_remove_alias(const char* const name); gboolean prefs_remove_alias(const char* const name);
char* prefs_get_alias(const char* const name); gchar* prefs_get_alias(const char* const name);
GList* prefs_get_aliases(void); GList* prefs_get_aliases(void);
void prefs_free_aliases(GList* aliases); void prefs_free_aliases(GList* aliases);

View File

@ -54,7 +54,7 @@
void void
scripts_init(void) scripts_init(void)
{ {
char* scriptsdir = files_get_data_path(DIR_SCRIPTS); auto_gchar gchar* scriptsdir = files_get_data_path(DIR_SCRIPTS);
// mkdir if doesn't exist // mkdir if doesn't exist
errno = 0; errno = 0;
@ -67,18 +67,15 @@ scripts_init(void)
log_error("Error creating directory: %s", scriptsdir); log_error("Error creating directory: %s", scriptsdir);
} }
} }
free(scriptsdir);
} }
GSList* GSList*
scripts_list(void) scripts_list(void)
{ {
char* scriptsdir = files_get_data_path(DIR_SCRIPTS); auto_gchar gchar* scriptsdir = files_get_data_path(DIR_SCRIPTS);
GSList* result = NULL; GSList* result = NULL;
GDir* scripts = g_dir_open(scriptsdir, 0, NULL); GDir* scripts = g_dir_open(scriptsdir, 0, NULL);
free(scriptsdir);
if (scripts) { if (scripts) {
const gchar* script = g_dir_read_name(scripts); const gchar* script = g_dir_read_name(scripts);
@ -95,9 +92,8 @@ scripts_list(void)
GSList* GSList*
scripts_read(const char* const script) scripts_read(const char* const script)
{ {
char* scriptsdir = files_get_data_path(DIR_SCRIPTS); auto_gchar gchar* scriptsdir = files_get_data_path(DIR_SCRIPTS);
GString* scriptpath = g_string_new(scriptsdir); GString* scriptpath = g_string_new(scriptsdir);
free(scriptsdir);
g_string_append(scriptpath, "/"); g_string_append(scriptpath, "/");
g_string_append(scriptpath, script); g_string_append(scriptpath, script);
@ -110,7 +106,7 @@ scripts_read(const char* const script)
g_string_free(scriptpath, TRUE); g_string_free(scriptpath, TRUE);
char* line = NULL; auto_char char* line = NULL;
size_t len = 0; size_t len = 0;
GSList* result = NULL; GSList* result = NULL;
@ -123,8 +119,6 @@ scripts_read(const char* const script)
} }
fclose(scriptfile); fclose(scriptfile);
if (line)
free(line);
return result; return result;
} }
@ -132,9 +126,8 @@ scripts_read(const char* const script)
gboolean gboolean
scripts_exec(const char* const script) scripts_exec(const char* const script)
{ {
char* scriptsdir = files_get_data_path(DIR_SCRIPTS); auto_gchar gchar* scriptsdir = files_get_data_path(DIR_SCRIPTS);
GString* scriptpath = g_string_new(scriptsdir); GString* scriptpath = g_string_new(scriptsdir);
free(scriptsdir);
g_string_append(scriptpath, "/"); g_string_append(scriptpath, "/");
g_string_append(scriptpath, script); g_string_append(scriptpath, script);
@ -147,7 +140,7 @@ scripts_exec(const char* const script)
g_string_free(scriptpath, TRUE); g_string_free(scriptpath, TRUE);
char* line = NULL; auto_char char* line = NULL;
size_t len = 0; size_t len = 0;
while (getline(&line, &len, scriptfile) != -1) { while (getline(&line, &len, scriptfile) != -1) {
@ -158,8 +151,6 @@ scripts_exec(const char* const script)
} }
fclose(scriptfile); fclose(scriptfile);
if (line)
free(line);
return TRUE; return TRUE;
} }

View File

@ -83,7 +83,7 @@ log_database_init(ProfAccount* account)
return FALSE; return FALSE;
} }
char* filename = _get_db_filename(account); auto_char char* filename = _get_db_filename(account);
if (!filename) { if (!filename) {
return FALSE; return FALSE;
} }
@ -92,7 +92,6 @@ log_database_init(ProfAccount* account)
if (ret != SQLITE_OK) { if (ret != SQLITE_OK) {
const char* err_msg = sqlite3_errmsg(g_chatlog_database); const char* err_msg = sqlite3_errmsg(g_chatlog_database);
log_error("Error opening SQLite database: %s", err_msg); log_error("Error opening SQLite database: %s", err_msg);
free(filename);
return FALSE; return FALSE;
} }
@ -126,7 +125,6 @@ log_database_init(ProfAccount* account)
} }
log_debug("Initialized SQLite database: %s", filename); log_debug("Initialized SQLite database: %s", filename);
free(filename);
return TRUE; return TRUE;
out: out:
@ -136,7 +134,6 @@ out:
} else { } else {
log_error("Unknown SQLite error"); log_error("Unknown SQLite error");
} }
free(filename);
return FALSE; return FALSE;
} }

View File

@ -110,7 +110,7 @@ cl_ev_reconnect(void)
void void
cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs) cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs)
{ {
char* signed_status = NULL; auto_char char* signed_status = NULL;
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
char* account_name = session_get_account_name(); char* account_name = session_get_account_name();
@ -123,8 +123,6 @@ cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs
#endif #endif
presence_send(presence_type, idle_secs, signed_status); presence_send(presence_type, idle_secs, signed_status);
free(signed_status);
} }
void void
@ -134,7 +132,7 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
gboolean request_receipt = prefs_get_boolean(PREF_RECEIPTS_REQUEST); gboolean request_receipt = prefs_get_boolean(PREF_RECEIPTS_REQUEST);
char* plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg); auto_char char* plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
if (plugin_msg == NULL) { if (plugin_msg == NULL) {
return; return;
} }
@ -146,33 +144,30 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
if (chatwin->is_omemo) { if (chatwin->is_omemo) {
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
char* id = omemo_on_message_send((ProfWin*)chatwin, plugin_msg, request_receipt, FALSE, replace_id); auto_char char* id = omemo_on_message_send((ProfWin*)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
if (id != NULL) { if (id != NULL) {
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id);
free(id);
} }
#endif #endif
} else if (chatwin->is_ox) { } else if (chatwin->is_ox) {
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
// XEP-0373: OpenPGP for XMPP // XEP-0373: OpenPGP for XMPP
char* id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id); auto_char char* id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id);
if (id != NULL) { if (id != NULL) {
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OX); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OX);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OX, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OX, request_receipt, replace_id);
free(id);
} }
#endif #endif
} else if (chatwin->pgp_send) { } else if (chatwin->pgp_send) {
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
char* id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id); auto_char char* id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
if (id != NULL) { if (id != NULL) {
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_PGP); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_PGP);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
free(id);
} }
#endif #endif
} else { } else {
@ -181,16 +176,14 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id); handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
#endif #endif
if (!handled) { if (!handled) {
char* id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id); auto_char char* id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_NONE); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_NONE);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_NONE, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_NONE, request_receipt, replace_id);
free(id);
} }
} }
plugins_post_chat_message_send(chatwin->barejid, plugin_msg); plugins_post_chat_message_send(chatwin->barejid, plugin_msg);
free(plugin_msg);
return; return;
} }
@ -203,7 +196,7 @@ cl_ev_send_msg(ProfChatWin* chatwin, const char* const msg, const char* const oo
void void
cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg) cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg)
{ {
char* plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg); auto_char char* plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg);
if (plugin_msg == NULL) { if (plugin_msg == NULL) {
return; return;
} }
@ -215,33 +208,28 @@ cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const ch
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
if (mucwin->is_omemo) { if (mucwin->is_omemo) {
char* id = omemo_on_message_send((ProfWin*)mucwin, plugin_msg, FALSE, TRUE, replace_id); auto_char char* id = omemo_on_message_send((ProfWin*)mucwin, plugin_msg, FALSE, TRUE, replace_id);
groupchat_log_omemo_msg_out(mucwin->roomjid, plugin_msg); groupchat_log_omemo_msg_out(mucwin->roomjid, plugin_msg);
log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO); log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO);
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, replace_id); mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, replace_id);
free(id);
} else { } else {
char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id); auto_char char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id);
groupchat_log_msg_out(mucwin->roomjid, plugin_msg); groupchat_log_msg_out(mucwin->roomjid, plugin_msg);
log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE); log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE);
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id); mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id);
free(id);
} }
plugins_post_room_message_send(mucwin->roomjid, plugin_msg); plugins_post_room_message_send(mucwin->roomjid, plugin_msg);
free(plugin_msg);
return; return;
#endif #endif
#ifndef HAVE_OMEMO #ifndef HAVE_OMEMO
char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id); auto_char char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id);
groupchat_log_msg_out(mucwin->roomjid, plugin_msg); groupchat_log_msg_out(mucwin->roomjid, plugin_msg);
log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE); log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE);
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id); mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id);
free(id);
plugins_post_room_message_send(mucwin->roomjid, plugin_msg); plugins_post_room_message_send(mucwin->roomjid, plugin_msg);
free(plugin_msg);
return; return;
#endif #endif
} }
@ -260,18 +248,14 @@ cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char*
} else if (privwin->room_left) { } else if (privwin->room_left) {
privwin_message_left_room(privwin); privwin_message_left_room(privwin);
} else { } else {
char* plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg); auto_char char* plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg);
Jid* jidp = jid_create(privwin->fulljid); auto_jid Jid* jidp = jid_create(privwin->fulljid);
char* id = message_send_private(privwin->fulljid, plugin_msg, oob_url); auto_char char* id = message_send_private(privwin->fulljid, plugin_msg, oob_url);
chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart); chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart);
log_database_add_outgoing_muc_pm(id, privwin->fulljid, plugin_msg, NULL, PROF_MSG_ENC_NONE); log_database_add_outgoing_muc_pm(id, privwin->fulljid, plugin_msg, NULL, PROF_MSG_ENC_NONE);
privwin_outgoing_msg(privwin, plugin_msg); privwin_outgoing_msg(privwin, plugin_msg);
free(id);
plugins_post_priv_message_send(privwin->fulljid, plugin_msg); plugins_post_priv_message_send(privwin->fulljid, plugin_msg);
free(plugin_msg);
jid_destroy(jidp);
} }
} }

View File

@ -151,11 +151,10 @@ sv_ev_roster_received(void)
// check pgp key valid if specified // check pgp key valid if specified
ProfAccount* account = accounts_get_account(account_name); ProfAccount* account = accounts_get_account(account_name);
if (account && account->pgp_keyid) { if (account && account->pgp_keyid) {
char* err_str = NULL; auto_char char* err_str = NULL;
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) { if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
cons_show_error("Invalid PGP key ID specified: %s, %s", account->pgp_keyid, err_str); cons_show_error("Invalid PGP key ID specified: %s, %s", account->pgp_keyid, err_str);
} }
free(err_str);
// Redraw the screen after entry of the PGP secret key, but not init // Redraw the screen after entry of the PGP secret key, but not init
ProfWin* win = wins_get_current(); ProfWin* win = wins_get_current();
@ -633,13 +632,12 @@ sv_ev_incoming_message(ProfMessage* message)
char* looking_for_jid = message->from_jid->barejid; char* looking_for_jid = message->from_jid->barejid;
if (message->is_mam) { if (message->is_mam) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) {
if (message->to_jid) { if (message->to_jid) {
looking_for_jid = message->to_jid->barejid; looking_for_jid = message->to_jid->barejid;
} }
} }
free(mybarejid);
} }
chatwin = wins_get_chat(looking_for_jid); chatwin = wins_get_chat(looking_for_jid);
@ -1106,14 +1104,13 @@ sv_ev_muc_occupant_online(const char* const room, const char* const nick, const
} }
// handle nickname change // handle nickname change
char* old_nick = muc_roster_nick_change_complete(room, nick); auto_char char* old_nick = muc_roster_nick_change_complete(room, nick);
if (old_nick) { if (old_nick) {
ProfMucWin* mucwin = wins_get_muc(room); ProfMucWin* mucwin = wins_get_muc(room);
if (mucwin) { if (mucwin) {
mucwin_occupant_nick_change(mucwin, old_nick, nick); mucwin_occupant_nick_change(mucwin, old_nick, nick);
wins_private_nick_change(mucwin->roomjid, old_nick, nick); wins_private_nick_change(mucwin->roomjid, old_nick, nick);
} }
free(old_nick);
occupantswin_occupants(room); occupantswin_occupants(room);
rosterwin_roster(); rosterwin_roster();
@ -1199,7 +1196,7 @@ sv_ev_certfail(const char* const errormsg, const TLSCertificate* cert)
cons_show(""); cons_show("");
ui_update(); ui_update();
char* cmd = ui_get_line(); auto_char char* cmd = ui_get_line();
while ((g_strcmp0(cmd, "/tls allow") != 0) while ((g_strcmp0(cmd, "/tls allow") != 0)
&& (g_strcmp0(cmd, "/tls always") != 0) && (g_strcmp0(cmd, "/tls always") != 0)
@ -1217,7 +1214,6 @@ sv_ev_certfail(const char* const errormsg, const TLSCertificate* cert)
if (g_strcmp0(cmd, "/tls allow") == 0) { if (g_strcmp0(cmd, "/tls allow") == 0) {
cons_show("Continuing with connection."); cons_show("Continuing with connection.");
tlscerts_set_current(cert->fingerprint); tlscerts_set_current(cert->fingerprint);
free(cmd);
return 1; return 1;
} else if (g_strcmp0(cmd, "/tls always") == 0) { } else if (g_strcmp0(cmd, "/tls always") == 0) {
cons_show("Adding %s to trusted certificates.", cert->fingerprint); cons_show("Adding %s to trusted certificates.", cert->fingerprint);
@ -1225,17 +1221,14 @@ sv_ev_certfail(const char* const errormsg, const TLSCertificate* cert)
tlscerts_add(cert); tlscerts_add(cert);
cafile_add(cert); cafile_add(cert);
} }
free(cmd);
return 1; return 1;
} else if (g_strcmp0(cmd, "/quit") == 0) { } else if (g_strcmp0(cmd, "/quit") == 0) {
prof_set_quit(); prof_set_quit();
free(cmd);
return 0;
} else {
cons_show("Aborting connection.");
free(cmd);
return 0; return 0;
} }
cons_show("Aborting connection.");
return 0;
} }
void void
@ -1313,7 +1306,7 @@ sv_ev_bookmark_autojoin(Bookmark* bookmark)
return; return;
} }
char* nick = NULL; auto_char char* nick = NULL;
if (bookmark->nick) { if (bookmark->nick) {
nick = strdup(bookmark->nick); nick = strdup(bookmark->nick);
@ -1332,8 +1325,6 @@ sv_ev_bookmark_autojoin(Bookmark* bookmark)
iq_room_affiliation_list(bookmark->barejid, "admin", false); iq_room_affiliation_list(bookmark->barejid, "admin", false);
iq_room_affiliation_list(bookmark->barejid, "owner", false); iq_room_affiliation_list(bookmark->barejid, "owner", false);
} }
free(nick);
} }
static void static void

View File

@ -73,9 +73,9 @@ enum {
static void static void
_rotate_log_file(void) _rotate_log_file(void)
{ {
gchar* log_file = g_strdup(mainlogfile); auto_gchar gchar* log_file = g_strdup(mainlogfile);
size_t len = strlen(log_file); size_t len = strlen(log_file);
gchar* log_file_new = malloc(len + 5); auto_gchar gchar* log_file_new = malloc(len + 5);
// the mainlog file should always end in '.log', lets remove this last part // the mainlog file should always end in '.log', lets remove this last part
// so that we can have profanity.001.log later // so that we can have profanity.001.log later
@ -100,8 +100,6 @@ _rotate_log_file(void)
log_init(log_get_filter(), NULL); log_init(log_get_filter(), NULL);
free(log_file_new);
free(log_file);
log_info("Log has been rotated"); log_info("Log has been rotated");
} }

View File

@ -392,12 +392,10 @@ omemo_publish_crypto_materials(void)
static void static void
_acquire_sender_devices_list(void) _acquire_sender_devices_list(void)
{ {
char* barejid = connection_get_barejid(); auto_char char* barejid = connection_get_barejid();
g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_own_device_list); g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_own_device_list);
omemo_devicelist_request(barejid); omemo_devicelist_request(barejid);
free(barejid);
} }
void void
@ -430,11 +428,10 @@ omemo_start_session(const char* const barejid)
log_debug("[OMEMO] missing device list for %s", barejid); log_debug("[OMEMO] missing device list for %s", barejid);
// Own devices are handled by _handle_own_device_list // Own devices are handled by _handle_own_device_list
// We won't add _handle_device_list_start_session for ourself // We won't add _handle_device_list_start_session for ourself
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
if (g_strcmp0(mybarejid, barejid) != 0) { if (g_strcmp0(mybarejid, barejid) != 0) {
g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_device_list_start_session); g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_device_list_start_session);
} }
free(mybarejid);
omemo_devicelist_request(barejid); omemo_devicelist_request(barejid);
return; return;
} }
@ -689,10 +686,9 @@ omemo_start_device_session(const char* const jid, uint32_t device_id,
auto_gchar gchar* trust_mode = prefs_get_string(PREF_OMEMO_TRUST_MODE); auto_gchar gchar* trust_mode = prefs_get_string(PREF_OMEMO_TRUST_MODE);
if ((g_strcmp0(trust_mode, "blind") == 0) && !trusted) { if ((g_strcmp0(trust_mode, "blind") == 0) && !trusted) {
char* fp = _omemo_fingerprint(identity_key, TRUE); auto_char char* fp = _omemo_fingerprint(identity_key, TRUE);
cons_show("Blind trust for %s device %d (%s)", jid, device_id, fp); cons_show("Blind trust for %s device %d (%s)", jid, device_id, fp);
omemo_trust(jid, fp); omemo_trust(jid, fp);
free(fp);
trusted = TRUE; trusted = TRUE;
} }

View File

@ -122,15 +122,14 @@ static void
cb_inject_message(void* opdata, const char* accountname, cb_inject_message(void* opdata, const char* accountname,
const char* protocol, const char* recipient, const char* message) const char* protocol, const char* recipient, const char* message)
{ {
char* id = message_send_chat_otr(recipient, message, FALSE, NULL); free(message_send_chat_otr(recipient, message, FALSE, NULL));
free(id);
} }
static void static void
cb_write_fingerprints(void* opdata) cb_write_fingerprints(void* opdata)
{ {
gcry_error_t err = 0; gcry_error_t err = 0;
gchar* fpsfilename = files_file_in_account_data_path(DIR_OTR, jid, "fingerprints.txt"); auto_gchar gchar* fpsfilename = files_file_in_account_data_path(DIR_OTR, jid, "fingerprints.txt");
if (!fpsfilename) { if (!fpsfilename) {
log_error("Failed to create fingerprints file"); log_error("Failed to create fingerprints file");
cons_show_error("Failed to create fingerprints file"); cons_show_error("Failed to create fingerprints file");
@ -142,8 +141,6 @@ cb_write_fingerprints(void* opdata)
log_error("Failed to write fingerprints file"); log_error("Failed to write fingerprints file");
cons_show_error("Failed to write fingerprints file"); cons_show_error("Failed to write fingerprints file");
} }
g_free(fpsfilename);
} }
static void static void
@ -305,8 +302,7 @@ otr_on_message_recv(const char* const barejid, const char* const resource, const
memmove(whitespace_base, whitespace_base + tag_length, tag_length); memmove(whitespace_base, whitespace_base + tag_length, tag_length);
char* otr_query_message = otr_start_query(); char* otr_query_message = otr_start_query();
cons_show("OTR Whitespace pattern detected. Attempting to start OTR session…"); cons_show("OTR Whitespace pattern detected. Attempting to start OTR session…");
char* id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); free(message_send_chat_otr(barejid, otr_query_message, FALSE, NULL));
free(id);
} }
} }
} }
@ -319,8 +315,7 @@ otr_on_message_recv(const char* const barejid, const char* const resource, const
if (policy == PROF_OTRPOLICY_ALWAYS && *decrypted == FALSE && !whitespace_base) { if (policy == PROF_OTRPOLICY_ALWAYS && *decrypted == FALSE && !whitespace_base) {
char* otr_query_message = otr_start_query(); char* otr_query_message = otr_start_query();
cons_show("Attempting to start OTR session…"); cons_show("Attempting to start OTR session…");
char* id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); free(message_send_chat_otr(barejid, otr_query_message, FALSE, NULL));
free(id);
} }
return newmessage; return newmessage;
@ -329,7 +324,7 @@ otr_on_message_recv(const char* const barejid, const char* const resource, const
gboolean gboolean
otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean request_receipt, const char* const replace_id) otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean request_receipt, const char* const replace_id)
{ {
char* id = NULL; auto_char char* id = NULL;
prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid); prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
// Send encrypted message // Send encrypted message
@ -341,7 +336,6 @@ otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean re
log_database_add_outgoing_chat(id, chatwin->barejid, message, replace_id, PROF_MSG_ENC_OTR); log_database_add_outgoing_chat(id, chatwin->barejid, message, replace_id, PROF_MSG_ENC_OTR);
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt, replace_id);
otr_free_message(encrypted); otr_free_message(encrypted);
free(id);
return TRUE; return TRUE;
} else { } else {
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "%s", "Failed to encrypt and send message."); win_println((ProfWin*)chatwin, THEME_ERROR, "-", "%s", "Failed to encrypt and send message.");
@ -357,12 +351,10 @@ otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean re
// tag and send for policy opportunistic // tag and send for policy opportunistic
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) { if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
char* otr_tagged_msg = otr_tag_message(message); auto_char char* otr_tagged_msg = otr_tag_message(message);
id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt, replace_id); id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt, replace_id);
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_NONE, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_NONE, request_receipt, replace_id);
chat_log_msg_out(chatwin->barejid, message, NULL); chat_log_msg_out(chatwin->barejid, message, NULL);
free(otr_tagged_msg);
free(id);
return TRUE; return TRUE;
} }

View File

@ -94,10 +94,9 @@ _p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_in
} else { } else {
GString* pass_term = g_string_new(""); GString* pass_term = g_string_new("");
char* password = ui_ask_pgp_passphrase(uid_hint, prev_was_bad); auto_char char* password = ui_ask_pgp_passphrase(uid_hint, prev_was_bad);
if (password) { if (password) {
g_string_append(pass_term, password); g_string_append(pass_term, password);
free(password);
} }
g_string_append(pass_term, "\n"); g_string_append(pass_term, "\n");
@ -462,10 +461,9 @@ p_gpg_verify(const char* const barejid, const char* const sign)
return; return;
} }
char* sign_with_header_footer = _add_header_footer(sign, PGP_SIGNATURE_HEADER, PGP_SIGNATURE_FOOTER); auto_char char* sign_with_header_footer = _add_header_footer(sign, PGP_SIGNATURE_HEADER, PGP_SIGNATURE_FOOTER);
gpgme_data_t sign_data; gpgme_data_t sign_data;
gpgme_data_new_from_mem(&sign_data, sign_with_header_footer, strlen(sign_with_header_footer), 1); gpgme_data_new_from_mem(&sign_data, sign_with_header_footer, strlen(sign_with_header_footer), 1);
free(sign_with_header_footer);
gpgme_data_t plain_data; gpgme_data_t plain_data;
gpgme_data_new(&plain_data); gpgme_data_new(&plain_data);
@ -533,7 +531,7 @@ p_gpg_sign(const char* const str, const char* const fp)
return NULL; return NULL;
} }
char* str_or_empty = NULL; auto_char char* str_or_empty = NULL;
if (str) { if (str) {
str_or_empty = strdup(str); str_or_empty = strdup(str);
} else { } else {
@ -541,7 +539,6 @@ p_gpg_sign(const char* const str, const char* const fp)
} }
gpgme_data_t str_data; gpgme_data_t str_data;
gpgme_data_new_from_mem(&str_data, str_or_empty, strlen(str_or_empty), 1); gpgme_data_new_from_mem(&str_data, str_or_empty, strlen(str_or_empty), 1);
free(str_or_empty);
gpgme_data_t signed_data; gpgme_data_t signed_data;
gpgme_data_new(&signed_data); gpgme_data_new(&signed_data);
@ -664,10 +661,9 @@ p_gpg_decrypt(const char* const cipher)
gpgme_set_passphrase_cb(ctx, (gpgme_passphrase_cb_t)_p_gpg_passphrase_cb, NULL); gpgme_set_passphrase_cb(ctx, (gpgme_passphrase_cb_t)_p_gpg_passphrase_cb, NULL);
char* cipher_with_headers = _add_header_footer(cipher, PGP_MESSAGE_HEADER, PGP_MESSAGE_FOOTER); auto_char char* cipher_with_headers = _add_header_footer(cipher, PGP_MESSAGE_HEADER, PGP_MESSAGE_FOOTER);
gpgme_data_t cipher_data; gpgme_data_t cipher_data;
gpgme_data_new_from_mem(&cipher_data, cipher_with_headers, strlen(cipher_with_headers), 1); gpgme_data_new_from_mem(&cipher_data, cipher_with_headers, strlen(cipher_with_headers), 1);
free(cipher_with_headers);
gpgme_data_t plain_data; gpgme_data_t plain_data;
gpgme_data_new(&plain_data); gpgme_data_new(&plain_data);

View File

@ -71,9 +71,8 @@ api_cons_show(const char* const message)
return 0; return 0;
} }
char* parsed = str_replace(message, "\r\n", "\n"); auto_char char* parsed = str_replace(message, "\r\n", "\n");
cons_show("%s", parsed); cons_show("%s", parsed);
free(parsed);
return 1; return 1;
} }
@ -86,13 +85,11 @@ api_cons_show_themed(const char* const group, const char* const key, const char*
return 0; return 0;
} }
char* parsed = str_replace(message, "\r\n", "\n"); auto_char char* parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def); theme_item_t themeitem = plugin_themes_get(group, key, def);
ProfWin* console = wins_get_console(); ProfWin* console = wins_get_console();
win_println(console, themeitem, "-", "%s", parsed); win_println(console, themeitem, "-", "%s", parsed);
free(parsed);
return 1; return 1;
} }
@ -798,9 +795,8 @@ api_chat_show(const char* const barejid, const char* message)
return 0; return 0;
} }
char* parsed = str_replace(message, "\r\n", "\n"); auto_char char* parsed = str_replace(message, "\r\n", "\n");
win_println((ProfWin*)chatwin, THEME_TEXT, "-", "%s", parsed); win_println((ProfWin*)chatwin, THEME_TEXT, "-", "%s", parsed);
free(parsed);
return 1; return 1;
} }
@ -835,11 +831,10 @@ api_chat_show_themed(const char* const barejid, const char* const group, const c
return 0; return 0;
} }
char* parsed = str_replace(message, "\r\n", "\n"); auto_char char* parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def); theme_item_t themeitem = plugin_themes_get(group, key, def);
win_println((ProfWin*)chatwin, themeitem, show_ch, "%s", parsed); win_println((ProfWin*)chatwin, themeitem, show_ch, "%s", parsed);
free(parsed);
return 1; return 1;
} }
@ -863,9 +858,8 @@ api_room_show(const char* const roomjid, const char* message)
return 0; return 0;
} }
char* parsed = str_replace(message, "\r\n", "\n"); auto_char char* parsed = str_replace(message, "\r\n", "\n");
win_println((ProfWin*)mucwin, THEME_TEXT, "-", "%s", parsed); win_println((ProfWin*)mucwin, THEME_TEXT, "-", "%s", parsed);
free(parsed);
return 1; return 1;
} }
@ -900,11 +894,10 @@ api_room_show_themed(const char* const roomjid, const char* const group, const c
return 0; return 0;
} }
char* parsed = str_replace(message, "\r\n", "\n"); auto_char char* parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def); theme_item_t themeitem = plugin_themes_get(group, key, def);
win_println((ProfWin*)mucwin, themeitem, show_ch, "%s", parsed); win_println((ProfWin*)mucwin, themeitem, show_ch, "%s", parsed);
free(parsed);
return 1; return 1;
} }

View File

@ -91,72 +91,60 @@ c_api_register_command(const char* filename, const char* command_name, int min_a
char** synopsis, const char* description, char* arguments[][2], char** examples, char** synopsis, const char* description, char* arguments[][2], char** examples,
void (*callback)(char** args)) void (*callback)(char** args))
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
log_debug("Register command %s for %s", command_name, plugin_name); log_debug("Register command %s for %s", command_name, plugin_name);
CommandWrapper* wrapper = malloc(sizeof(CommandWrapper)); CommandWrapper* wrapper = malloc(sizeof(CommandWrapper));
wrapper->func = callback; wrapper->func = callback;
api_register_command(plugin_name, command_name, min_args, max_args, synopsis, api_register_command(plugin_name, command_name, min_args, max_args, synopsis,
description, arguments, examples, wrapper, c_command_callback, free); description, arguments, examples, wrapper, c_command_callback, free);
free(plugin_name);
} }
static void static void
c_api_register_timed(const char* filename, void (*callback)(void), int interval_seconds) c_api_register_timed(const char* filename, void (*callback)(void), int interval_seconds)
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
log_debug("Register timed for %s", plugin_name); log_debug("Register timed for %s", plugin_name);
TimedWrapper* wrapper = malloc(sizeof(TimedWrapper)); TimedWrapper* wrapper = malloc(sizeof(TimedWrapper));
wrapper->func = callback; wrapper->func = callback;
api_register_timed(plugin_name, wrapper, interval_seconds, c_timed_callback, free); api_register_timed(plugin_name, wrapper, interval_seconds, c_timed_callback, free);
free(plugin_name);
} }
static void static void
c_api_completer_add(const char* filename, const char* key, char** items) c_api_completer_add(const char* filename, const char* key, char** items)
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete add %s for %s", key, plugin_name); log_debug("Autocomplete add %s for %s", key, plugin_name);
api_completer_add(plugin_name, key, items); api_completer_add(plugin_name, key, items);
free(plugin_name);
} }
static void static void
c_api_completer_remove(const char* filename, const char* key, char** items) c_api_completer_remove(const char* filename, const char* key, char** items)
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete remove %s for %s", key, plugin_name); log_debug("Autocomplete remove %s for %s", key, plugin_name);
api_completer_remove(plugin_name, key, items); api_completer_remove(plugin_name, key, items);
free(plugin_name);
} }
static void static void
c_api_completer_clear(const char* filename, const char* key) c_api_completer_clear(const char* filename, const char* key)
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete clear %s for %s", key, plugin_name); log_debug("Autocomplete clear %s for %s", key, plugin_name);
api_completer_clear(plugin_name, key); api_completer_clear(plugin_name, key);
free(plugin_name);
} }
static void static void
c_api_filepath_completer_add(const char* filename, const char* prefix) c_api_filepath_completer_add(const char* filename, const char* prefix)
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
log_debug("Filepath autocomplete added '%s' for %s", prefix, plugin_name); log_debug("Filepath autocomplete added '%s' for %s", prefix, plugin_name);
api_filepath_completer_add(plugin_name, prefix); api_filepath_completer_add(plugin_name, prefix);
free(plugin_name);
} }
static void static void
@ -252,13 +240,11 @@ c_api_win_exists(char* tag)
static void static void
c_api_win_create(const char* filename, char* tag, void (*callback)(char* tag, char* line)) c_api_win_create(const char* filename, char* tag, void (*callback)(char* tag, char* line))
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
WindowWrapper* wrapper = malloc(sizeof(WindowWrapper)); WindowWrapper* wrapper = malloc(sizeof(WindowWrapper));
wrapper->func = callback; wrapper->func = callback;
api_win_create(plugin_name, tag, wrapper, c_window_callback, free); api_win_create(plugin_name, tag, wrapper, c_window_callback, free);
free(plugin_name);
} }
static int static int
@ -354,9 +340,8 @@ c_api_incoming_message(char* barejid, char* resource, char* message)
static void static void
c_api_disco_add_feature(const char* filename, char* feature) c_api_disco_add_feature(const char* filename, char* feature)
{ {
char* plugin_name = _c_plugin_name(filename); auto_char char* plugin_name = _c_plugin_name(filename);
api_disco_add_feature(plugin_name, feature); api_disco_add_feature(plugin_name, feature);
free(plugin_name);
} }
static void static void

View File

@ -65,9 +65,8 @@ c_plugin_create(const char* const filename)
ProfPlugin* plugin; ProfPlugin* plugin;
void* handle = NULL; void* handle = NULL;
char* plugins_dir = files_get_data_path(DIR_PLUGINS); auto_gchar gchar* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* path = g_string_new(plugins_dir); GString* path = g_string_new(plugins_dir);
free(plugins_dir);
g_string_append(path, "/"); g_string_append(path, "/");
g_string_append(path, filename); g_string_append(path, filename);

View File

@ -172,9 +172,8 @@ gboolean
plugins_uninstall(const char* const plugin_name) plugins_uninstall(const char* const plugin_name)
{ {
plugins_unload(plugin_name); plugins_unload(plugin_name);
char* plugins_dir = files_get_data_path(DIR_PLUGINS); auto_gchar gchar* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* target_path = g_string_new(plugins_dir); GString* target_path = g_string_new(plugins_dir);
free(plugins_dir);
g_string_append(target_path, "/"); g_string_append(target_path, "/");
g_string_append(target_path, plugin_name); g_string_append(target_path, plugin_name);
GFile* file = g_file_new_for_path(target_path->str); GFile* file = g_file_new_for_path(target_path->str);
@ -189,9 +188,8 @@ plugins_uninstall(const char* const plugin_name)
gboolean gboolean
plugins_install(const char* const plugin_name, const char* const filename, GString* error_message) plugins_install(const char* const plugin_name, const char* const filename, GString* error_message)
{ {
char* plugins_dir = files_get_data_path(DIR_PLUGINS); auto_gchar gchar* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* target_path = g_string_new(plugins_dir); GString* target_path = g_string_new(plugins_dir);
free(plugins_dir);
g_string_append(target_path, "/"); g_string_append(target_path, "/");
g_string_append(target_path, plugin_name); g_string_append(target_path, plugin_name);
@ -387,9 +385,8 @@ GSList*
plugins_unloaded_list(void) plugins_unloaded_list(void)
{ {
GSList* result = NULL; GSList* result = NULL;
char* plugins_dir = files_get_data_path(DIR_PLUGINS); auto_gchar gchar* plugins_dir = files_get_data_path(DIR_PLUGINS);
_plugins_unloaded_list_dir(plugins_dir, &result); _plugins_unloaded_list_dir(plugins_dir, &result);
free(plugins_dir);
return result; return result;
} }

View File

@ -99,7 +99,7 @@ python_env_init(void)
python_init_prof(); python_init_prof();
char* plugins_dir = files_get_data_path(DIR_PLUGINS); auto_gchar gchar* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* path = g_string_new("import sys\n"); GString* path = g_string_new("import sys\n");
g_string_append(path, "sys.path.append(\""); g_string_append(path, "sys.path.append(\"");
g_string_append(path, plugins_dir); g_string_append(path, plugins_dir);
@ -109,7 +109,6 @@ python_env_init(void)
python_check_error(); python_check_error();
g_string_free(path, TRUE); g_string_free(path, TRUE);
g_free(plugins_dir);
allow_python_threads(); allow_python_threads();
} }

View File

@ -53,7 +53,7 @@ static void _save_settings(void);
void void
plugin_settings_init(void) plugin_settings_init(void)
{ {
char* settings_file = files_get_data_path(FILE_PLUGIN_SETTINGS); auto_gchar gchar* settings_file = files_get_data_path(FILE_PLUGIN_SETTINGS);
if (g_file_test(settings_file, G_FILE_TEST_EXISTS)) { if (g_file_test(settings_file, G_FILE_TEST_EXISTS)) {
g_chmod(settings_file, S_IRUSR | S_IWUSR); g_chmod(settings_file, S_IRUSR | S_IWUSR);
@ -63,11 +63,9 @@ plugin_settings_init(void)
g_key_file_load_from_file(settings, settings_file, G_KEY_FILE_KEEP_COMMENTS, NULL); g_key_file_load_from_file(settings, settings_file, G_KEY_FILE_KEEP_COMMENTS, NULL);
gsize g_data_size; gsize g_data_size;
gchar* g_data = g_key_file_to_data(settings, &g_data_size, NULL); auto_gchar gchar* g_data = g_key_file_to_data(settings, &g_data_size, NULL);
g_file_set_contents(settings_file, g_data, g_data_size, NULL); g_file_set_contents(settings_file, g_data, g_data_size, NULL);
g_chmod(settings_file, S_IRUSR | S_IWUSR); g_chmod(settings_file, S_IRUSR | S_IWUSR);
g_free(g_data);
free(settings_file);
} }
void void
@ -175,15 +173,11 @@ static void
_save_settings(void) _save_settings(void)
{ {
gsize g_data_size; gsize g_data_size;
gchar* g_data = g_key_file_to_data(settings, &g_data_size, NULL); auto_gchar gchar* g_data = g_key_file_to_data(settings, &g_data_size, NULL);
char* fileloc = files_get_data_path(FILE_PLUGIN_SETTINGS); auto_gchar gchar* fileloc = files_get_data_path(FILE_PLUGIN_SETTINGS);
gchar* base = g_path_get_dirname(fileloc); auto_gchar gchar* base = g_path_get_dirname(fileloc);
gchar* true_loc = get_file_or_linked(fileloc, base); auto_gchar gchar* true_loc = get_file_or_linked(fileloc, base);
g_free(base);
g_file_set_contents(true_loc, g_data, g_data_size, NULL); g_file_set_contents(true_loc, g_data, g_data_size, NULL);
free(true_loc);
g_free(g_data);
g_chmod(fileloc, S_IRUSR | S_IWUSR); g_chmod(fileloc, S_IRUSR | S_IWUSR);
free(fileloc);
} }

View File

@ -49,7 +49,7 @@ static GKeyFile* themes;
void void
plugin_themes_init(void) plugin_themes_init(void)
{ {
char* themes_file = files_get_data_path(FILE_PLUGIN_THEMES); auto_gchar gchar* themes_file = files_get_data_path(FILE_PLUGIN_THEMES);
if (g_file_test(themes_file, G_FILE_TEST_EXISTS)) { if (g_file_test(themes_file, G_FILE_TEST_EXISTS)) {
g_chmod(themes_file, S_IRUSR | S_IWUSR); g_chmod(themes_file, S_IRUSR | S_IWUSR);
@ -59,11 +59,9 @@ plugin_themes_init(void)
g_key_file_load_from_file(themes, themes_file, G_KEY_FILE_KEEP_COMMENTS, NULL); g_key_file_load_from_file(themes, themes_file, G_KEY_FILE_KEEP_COMMENTS, NULL);
gsize g_data_size; gsize g_data_size;
gchar* g_data = g_key_file_to_data(themes, &g_data_size, NULL); auto_gchar gchar* g_data = g_key_file_to_data(themes, &g_data_size, NULL);
g_file_set_contents(themes_file, g_data, g_data_size, NULL); g_file_set_contents(themes_file, g_data, g_data_size, NULL);
g_chmod(themes_file, S_IRUSR | S_IWUSR); g_chmod(themes_file, S_IRUSR | S_IWUSR);
g_free(g_data);
free(themes_file);
} }
void void

View File

@ -114,8 +114,8 @@ autocomplete_length(Autocomplete ac)
void void
autocomplete_update(Autocomplete ac, char** items) autocomplete_update(Autocomplete ac, char** items)
{ {
gchar* last_found = NULL; auto_gchar gchar* last_found = NULL;
gchar* search_str = NULL; auto_gchar gchar* search_str = NULL;
if (ac->last_found) { if (ac->last_found) {
last_found = strdup(ac->last_found->data); last_found = strdup(ac->last_found->data);
@ -131,12 +131,10 @@ autocomplete_update(Autocomplete ac, char** items)
if (last_found) { if (last_found) {
// NULL if last_found was removed on update. // NULL if last_found was removed on update.
ac->last_found = g_list_find_custom(ac->items, last_found, (GCompareFunc)strcmp); ac->last_found = g_list_find_custom(ac->items, last_found, (GCompareFunc)strcmp);
free(last_found);
} }
if (search_str) { if (search_str) {
ac->search_str = strdup(search_str); ac->search_str = strdup(search_str);
free(search_str);
} }
} }

View File

@ -52,9 +52,7 @@ static gchar* account_jid = NULL;
static void static void
_bookmark_ignore_load() _bookmark_ignore_load()
{ {
gchar* bi_loc; auto_gchar gchar* bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE);
bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE);
if (g_file_test(bi_loc, G_FILE_TEST_EXISTS)) { if (g_file_test(bi_loc, G_FILE_TEST_EXISTS)) {
g_chmod(bi_loc, S_IRUSR | S_IWUSR); g_chmod(bi_loc, S_IRUSR | S_IWUSR);
@ -62,24 +60,18 @@ _bookmark_ignore_load()
bookmark_ignore_keyfile = g_key_file_new(); bookmark_ignore_keyfile = g_key_file_new();
g_key_file_load_from_file(bookmark_ignore_keyfile, bi_loc, G_KEY_FILE_KEEP_COMMENTS, NULL); g_key_file_load_from_file(bookmark_ignore_keyfile, bi_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
g_free(bi_loc);
} }
static void static void
_bookmark_save() _bookmark_save()
{ {
gsize g_data_size; gsize g_data_size;
gchar* g_bookmark_ignore_data = g_key_file_to_data(bookmark_ignore_keyfile, &g_data_size, NULL); auto_gchar gchar* g_bookmark_ignore_data = g_key_file_to_data(bookmark_ignore_keyfile, &g_data_size, NULL);
gchar* bi_loc; auto_gchar gchar* bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE);
bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE);
g_file_set_contents(bi_loc, g_bookmark_ignore_data, g_data_size, NULL); g_file_set_contents(bi_loc, g_bookmark_ignore_data, g_data_size, NULL);
g_chmod(bi_loc, S_IRUSR | S_IWUSR); g_chmod(bi_loc, S_IRUSR | S_IWUSR);
g_free(bi_loc);
g_free(g_bookmark_ignore_data);
} }
void void

View File

@ -163,7 +163,7 @@ http_file_put(void* userdata)
FILE* fh = NULL; FILE* fh = NULL;
char* err = NULL; auto_char char* err = NULL;
gchar* content_type_header; gchar* content_type_header;
// Optional headers // Optional headers
gchar* auth_header = NULL; gchar* auth_header = NULL;
@ -318,7 +318,6 @@ http_file_put(void* userdata)
} }
cons_show_error(msg); cons_show_error(msg);
g_free(msg); g_free(msg);
free(err);
} else { } else {
if (!upload->cancel) { if (!upload->cancel) {
msg = g_strdup_printf("Uploading '%s': 100%%", upload->filename); msg = g_strdup_printf("Uploading '%s': 100%%", upload->filename);

View File

@ -51,7 +51,7 @@ _parse_args_helper(const char* const inp, int min, int max, gboolean* result, gb
} }
// copy and strip input of leading/trailing whitespace // copy and strip input of leading/trailing whitespace
char* copy = strdup(inp); auto_char char* copy = strdup(inp);
g_strstrip(copy); g_strstrip(copy);
int inp_size = g_utf8_strlen(copy, -1); int inp_size = g_utf8_strlen(copy, -1);
@ -135,8 +135,6 @@ _parse_args_helper(const char* const inp, int min, int max, gboolean* result, gb
tokens = g_slist_append(tokens, g_strndup(token_start, token_size)); tokens = g_slist_append(tokens, g_strndup(token_start, token_size));
} }
free(copy);
int num = g_slist_length(tokens) - 1; int num = g_slist_length(tokens) - 1;
// if num args not valid return NULL // if num args not valid return NULL

View File

@ -329,13 +329,12 @@ chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_cr
int num = wins_get_num(window); int num = wins_get_num(window);
auto_gchar gchar* display_name; auto_gchar gchar* display_name;
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) {
display_name = strdup("me"); display_name = strdup("me");
} else { } else {
display_name = roster_get_msg_display_name(message->from_jid->barejid, message->from_jid->resourcepart); display_name = roster_get_msg_display_name(message->from_jid->barejid, message->from_jid->resourcepart);
} }
free(mybarejid);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
if (prefs_get_boolean(PREF_PGP_PUBKEY_AUTOIMPORT)) { if (prefs_get_boolean(PREF_PGP_PUBKEY_AUTOIMPORT)) {
@ -431,7 +430,7 @@ chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id,
ProfWin* window = (ProfWin*)chatwin; ProfWin* window = (ProfWin*)chatwin;
wins_add_quotes_ac(window, message, FALSE); wins_add_quotes_ac(window, message, FALSE);
char* enc_char; auto_char char* enc_char;
if (chatwin->outgoing_char) { if (chatwin->outgoing_char) {
enc_char = chatwin->outgoing_char; enc_char = chatwin->outgoing_char;
} else if (enc_mode == PROF_MSG_ENC_OTR) { } else if (enc_mode == PROF_MSG_ENC_OTR) {
@ -452,8 +451,6 @@ chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id,
win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, message); win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, message);
} }
free(enc_char);
// save last id and message for LMC // save last id and message for LMC
if (id) { if (id) {
_chatwin_set_last_message(chatwin, id, message); _chatwin_set_last_message(chatwin, id, message);
@ -465,7 +462,7 @@ chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message)
{ {
assert(chatwin != NULL); assert(chatwin != NULL);
char* enc_char; auto_char char* enc_char;
if (message->enc == PROF_MSG_ENC_PGP) { if (message->enc == PROF_MSG_ENC_PGP) {
enc_char = prefs_get_pgp_char(); enc_char = prefs_get_pgp_char();
} else if (message->enc == PROF_MSG_ENC_OMEMO) { } else if (message->enc == PROF_MSG_ENC_OMEMO) {
@ -479,8 +476,6 @@ chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message)
win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain); win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain);
int num = wins_get_num(window); int num = wins_get_num(window);
status_bar_active(num, WIN_CHAT, chatwin->barejid); status_bar_active(num, WIN_CHAT, chatwin->barejid);
free(enc_char);
} }
void void
@ -490,11 +485,9 @@ chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last
const char* show = string_from_resource_presence(resource->presence); const char* show = string_from_resource_presence(resource->presence);
PContact contact = roster_get_contact(chatwin->barejid); PContact contact = roster_get_contact(chatwin->barejid);
char* display_str = p_contact_create_display_string(contact, resource->name); auto_char char* display_str = p_contact_create_display_string(contact, resource->name);
win_show_status_string((ProfWin*)chatwin, display_str, show, resource->status, last_activity, "++", "online"); win_show_status_string((ProfWin*)chatwin, display_str, show, resource->status, last_activity, "++", "online");
free(display_str);
} }
void void
@ -503,11 +496,9 @@ chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status)
assert(chatwin != NULL); assert(chatwin != NULL);
PContact contact = roster_get_contact(chatwin->barejid); PContact contact = roster_get_contact(chatwin->barejid);
char* display_str = p_contact_create_display_string(contact, resource); auto_char char* display_str = p_contact_create_display_string(contact, resource);
win_show_status_string((ProfWin*)chatwin, display_str, "offline", status, NULL, "--", "offline"); win_show_status_string((ProfWin*)chatwin, display_str, "offline", status, NULL, "--", "offline");
free(display_str);
} }
char* char*

View File

@ -337,9 +337,8 @@ cons_show_incoming_room_message(const char* const nick, const char* const room,
if (mention) { if (mention) {
win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index);
} else if (triggers) { } else if (triggers) {
char* triggers_str = _room_triggers_to_string(triggers); auto_char char* triggers_str = _room_triggers_to_string(triggers);
win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
free(triggers_str);
} else { } else {
// 'all' or 'first' if its the first message // 'all' or 'first' if its the first message
if ((g_strcmp0(muc_show, "all") == 0) || ((g_strcmp0(muc_show, "first") == 0) && (unread == 0))) { if ((g_strcmp0(muc_show, "all") == 0) || ((g_strcmp0(muc_show, "first") == 0) && (unread == 0))) {
@ -387,7 +386,7 @@ cons_show_incoming_private_message(const char* const nick, const char* const roo
static void static void
_cons_welcome_first_start(void) _cons_welcome_first_start(void)
{ {
gchar* ident_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER); auto_gchar gchar* ident_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER);
if (!g_file_test(ident_loc, G_FILE_TEST_EXISTS)) { if (!g_file_test(ident_loc, G_FILE_TEST_EXISTS)) {
ProfWin* console = wins_get_console(); ProfWin* console = wins_get_console();
win_println(console, THEME_DEFAULT, "-", "This seems to be your first time starting Profanity."); win_println(console, THEME_DEFAULT, "-", "This seems to be your first time starting Profanity.");
@ -402,7 +401,6 @@ _cons_welcome_first_start(void)
win_println(console, THEME_DEFAULT, "-", "/register myjid myserver.org"); win_println(console, THEME_DEFAULT, "-", "/register myjid myserver.org");
win_println(console, THEME_DEFAULT, "-", ""); win_println(console, THEME_DEFAULT, "-", "");
} }
g_free(ident_loc);
} }
void void
@ -452,26 +450,27 @@ void
cons_check_version(gboolean not_available_msg) cons_check_version(gboolean not_available_msg)
{ {
ProfWin* console = wins_get_console(); ProfWin* console = wins_get_console();
char* latest_release = release_get_latest(); auto_char char* latest_release = release_get_latest();
if (latest_release) { if (!latest_release) {
gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0); return;
}
if (relase_valid) { gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0);
if (release_is_new(latest_release)) {
win_println(console, THEME_DEFAULT, "-", "A new version of Profanity is available: %s", latest_release); if (relase_valid) {
win_println(console, THEME_DEFAULT, "-", "Check <https://profanity-im.github.io> for details."); if (release_is_new(latest_release)) {
win_println(console, THEME_DEFAULT, "-", "A new version of Profanity is available: %s", latest_release);
win_println(console, THEME_DEFAULT, "-", "Check <https://profanity-im.github.io> for details.");
win_println(console, THEME_DEFAULT, "-", "");
} else {
if (not_available_msg) {
win_println(console, THEME_DEFAULT, "-", "No new version available.");
win_println(console, THEME_DEFAULT, "-", ""); win_println(console, THEME_DEFAULT, "-", "");
} else {
if (not_available_msg) {
win_println(console, THEME_DEFAULT, "-", "No new version available.");
win_println(console, THEME_DEFAULT, "-", "");
}
} }
cons_alert(NULL);
} }
free(latest_release);
cons_alert(NULL);
} }
} }
@ -894,12 +893,10 @@ cons_show_qrcode(const char* const text)
ProfWin* console = wins_get_console(); ProfWin* console = wins_get_console();
char* buf = calloc((width * 4) + 1, 1); auto_char char* buf = calloc((width * 4) + 1, 1);
char* pad = calloc((width * 4) + 5, 1); auto_char char* pad = calloc((width * 4) + 5, 1);
if (!buf || !pad) { if (!buf || !pad) {
free(pad);
free(buf);
return; return;
} }
@ -926,9 +923,6 @@ cons_show_qrcode(const char* const text)
win_println(console, THEME_DEFAULT, "", ""); win_println(console, THEME_DEFAULT, "", "");
win_println(console, THEME_DEFAULT, "", ""); win_println(console, THEME_DEFAULT, "", "");
free(pad);
free(buf);
QRcode_free(qrcode); QRcode_free(qrcode);
#else #else
cons_show("This version of Profanity has not been built with libqrencode"); cons_show("This version of Profanity has not been built with libqrencode");
@ -953,7 +947,7 @@ cons_show_status(const char* const barejid)
void void
cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason) cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason)
{ {
char* display_from = NULL; auto_char char* display_from = NULL;
PContact contact = roster_get_contact(invitor); PContact contact = roster_get_contact(invitor);
if (contact) { if (contact) {
if (p_contact_name(contact)) { if (p_contact_name(contact)) {
@ -981,8 +975,6 @@ cons_show_room_invite(const char* const invitor, const char* const room, const c
notify_invite(display_from, room, reason); notify_invite(display_from, room, reason);
} }
free(display_from);
cons_alert(NULL); cons_alert(NULL);
} }
@ -1412,10 +1404,9 @@ cons_occupants_setting(void)
else else
cons_show("Occupants wrap (/occupants) : OFF"); cons_show("Occupants wrap (/occupants) : OFF");
char* occupants_ch = prefs_get_occupants_char(); auto_char char* occupants_ch = prefs_get_occupants_char();
if (occupants_ch) { if (occupants_ch) {
cons_show("Occupants char (/occupants) : %s", occupants_ch); cons_show("Occupants char (/occupants) : %s", occupants_ch);
free(occupants_ch);
} else { } else {
cons_show("Occupants char (/occupants) : none"); cons_show("Occupants char (/occupants) : none");
} }
@ -1426,10 +1417,9 @@ cons_occupants_setting(void)
int size = prefs_get_occupants_size(); int size = prefs_get_occupants_size();
cons_show("Occupants size (/occupants) : %d", size); cons_show("Occupants size (/occupants) : %d", size);
char* header_ch = prefs_get_occupants_header_char(); auto_char char* header_ch = prefs_get_occupants_header_char();
if (header_ch) { if (header_ch) {
cons_show("Occupants header char (/occupants) : %s", header_ch); cons_show("Occupants header char (/occupants) : %s", header_ch);
free(header_ch);
} else { } else {
cons_show("Occupants header char (/occupants) : none"); cons_show("Occupants header char (/occupants) : none");
} }
@ -1544,50 +1534,44 @@ cons_roster_setting(void)
else else
cons_show("Roster offline (/roster) : hide"); cons_show("Roster offline (/roster) : hide");
char* header_ch = prefs_get_roster_header_char(); auto_char char* header_ch = prefs_get_roster_header_char();
if (header_ch) { if (header_ch) {
cons_show("Roster header char (/roster) : %s", header_ch); cons_show("Roster header char (/roster) : %s", header_ch);
free(header_ch);
} else { } else {
cons_show("Roster header char (/roster) : none"); cons_show("Roster header char (/roster) : none");
} }
char* contact_ch = prefs_get_roster_contact_char(); auto_char char* contact_ch = prefs_get_roster_contact_char();
if (contact_ch) { if (contact_ch) {
cons_show("Roster contact char (/roster) : %s", contact_ch); cons_show("Roster contact char (/roster) : %s", contact_ch);
free(contact_ch);
} else { } else {
cons_show("Roster contact char (/roster) : none"); cons_show("Roster contact char (/roster) : none");
} }
char* resource_ch = prefs_get_roster_resource_char(); auto_char char* resource_ch = prefs_get_roster_resource_char();
if (resource_ch) { if (resource_ch) {
cons_show("Roster resource char (/roster) : %s", resource_ch); cons_show("Roster resource char (/roster) : %s", resource_ch);
free(resource_ch);
} else { } else {
cons_show("Roster resource char (/roster) : none"); cons_show("Roster resource char (/roster) : none");
} }
char* room_ch = prefs_get_roster_room_char(); auto_char char* room_ch = prefs_get_roster_room_char();
if (room_ch) { if (room_ch) {
cons_show("Roster room char (/roster) : %s", room_ch); cons_show("Roster room char (/roster) : %s", room_ch);
free(room_ch);
} else { } else {
cons_show("Roster room char (/roster) : none"); cons_show("Roster room char (/roster) : none");
} }
char* room_priv_ch = prefs_get_roster_room_private_char(); auto_char char* room_priv_ch = prefs_get_roster_room_private_char();
if (room_priv_ch) { if (room_priv_ch) {
cons_show("Roster room private char (/roster) : %s", room_priv_ch); cons_show("Roster room private char (/roster) : %s", room_priv_ch);
free(room_priv_ch);
} else { } else {
cons_show("Roster room private char (/roster) : none"); cons_show("Roster room private char (/roster) : none");
} }
char* private_ch = prefs_get_roster_private_char(); auto_char char* private_ch = prefs_get_roster_private_char();
if (private_ch) { if (private_ch) {
cons_show("Roster private char (/roster) : %s", private_ch); cons_show("Roster private char (/roster) : %s", private_ch);
free(private_ch);
} else { } else {
cons_show("Roster private char (/roster) : none"); cons_show("Roster private char (/roster) : none");
} }
@ -2207,9 +2191,8 @@ cons_correction_setting(void)
cons_show("Last Message Correction (XEP-0308) (/correction) : OFF"); cons_show("Last Message Correction (XEP-0308) (/correction) : OFF");
} }
char* cc = prefs_get_correction_char(); auto_char char* cc = prefs_get_correction_char();
cons_show("LMC indication char (/correction char) : %s", cc); cons_show("LMC indication char (/correction char) : %s", cc);
free(cc);
} }
void void
@ -2303,9 +2286,8 @@ cons_show_otr_prefs(void)
cons_show("OTR logging (/otr log) : Redacted"); cons_show("OTR logging (/otr log) : Redacted");
} }
char* ch = prefs_get_otr_char(); auto_char char* ch = prefs_get_otr_char();
cons_show("OTR char (/otr char) : %s", ch); cons_show("OTR char (/otr char) : %s", ch);
free(ch);
if (prefs_get_boolean(PREF_OTR_SENDFILE)) { if (prefs_get_boolean(PREF_OTR_SENDFILE)) {
cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): ON"); cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): ON");
@ -2331,9 +2313,8 @@ cons_show_pgp_prefs(void)
cons_show("PGP logging (/pgp log) : Redacted"); cons_show("PGP logging (/pgp log) : Redacted");
} }
char* ch = prefs_get_pgp_char(); auto_char char* ch = prefs_get_pgp_char();
cons_show("PGP char (/pgp char) : %s", ch); cons_show("PGP char (/pgp char) : %s", ch);
free(ch);
if (prefs_get_boolean(PREF_PGP_SENDFILE)) { if (prefs_get_boolean(PREF_PGP_SENDFILE)) {
cons_show("Allow sending unencrypted files via /sendfile while otherwise using PGP (/pgp sendfile): ON"); cons_show("Allow sending unencrypted files via /sendfile while otherwise using PGP (/pgp sendfile): ON");
@ -2362,9 +2343,8 @@ cons_show_omemo_prefs(void)
cons_show("OMEMO logging (/omemo log) : Redacted"); cons_show("OMEMO logging (/omemo log) : Redacted");
} }
char* ch = prefs_get_omemo_char(); auto_char char* ch = prefs_get_omemo_char();
cons_show("OMEMO char (/omemo char) : %s", ch); cons_show("OMEMO char (/omemo char) : %s", ch);
free(ch);
cons_alert(NULL); cons_alert(NULL);
} }
@ -2384,9 +2364,8 @@ cons_show_ox_prefs(void)
cons_show("OX logging (/ox log) : Redacted"); cons_show("OX logging (/ox log) : Redacted");
} }
char* ch = prefs_get_ox_char(); auto_char char* ch = prefs_get_ox_char();
cons_show("OX char (/ox char) : %s", ch); cons_show("OX char (/ox char) : %s", ch);
free(ch);
cons_alert(NULL); cons_alert(NULL);
} }
@ -2550,24 +2529,21 @@ void
cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity) cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity)
{ {
const char* show = string_from_resource_presence(resource->presence); const char* show = string_from_resource_presence(resource->presence);
char* display_str = p_contact_create_display_string(contact, resource->name); auto_char char* display_str = p_contact_create_display_string(contact, resource->name);
ProfWin* console = wins_get_console(); ProfWin* console = wins_get_console();
win_show_status_string(console, display_str, show, resource->status, last_activity, win_show_status_string(console, display_str, show, resource->status, last_activity,
"++", "online"); "++", "online");
free(display_str);
} }
void void
cons_show_contact_offline(PContact contact, char* resource, char* status) cons_show_contact_offline(PContact contact, char* resource, char* status)
{ {
char* display_str = p_contact_create_display_string(contact, resource); auto_char char* display_str = p_contact_create_display_string(contact, resource);
ProfWin* console = wins_get_console(); ProfWin* console = wins_get_console();
win_show_status_string(console, display_str, "offline", status, NULL, "--", win_show_status_string(console, display_str, "offline", status, NULL, "--",
"offline"); "offline");
free(display_str);
} }
void void
@ -2593,7 +2569,7 @@ cons_alert(ProfWin* alert_origin_window)
if (current->type != WIN_CONSOLE) { if (current->type != WIN_CONSOLE) {
status_bar_new(1, WIN_CONSOLE, "console"); status_bar_new(1, WIN_CONSOLE, "console");
char* win_name; auto_char char* win_name;
if (alert_origin_window) { if (alert_origin_window) {
win_name = win_to_string(alert_origin_window); win_name = win_to_string(alert_origin_window);
} else { } else {
@ -2604,8 +2580,6 @@ cons_alert(ProfWin* alert_origin_window)
if (!item) { if (!item) {
alert_list = g_list_append(alert_list, g_strdup(win_name)); alert_list = g_list_append(alert_list, g_strdup(win_name));
} }
free(win_name);
} }
} }
@ -2942,11 +2916,10 @@ cons_clear_alerts(void)
void void
cons_remove_alert(ProfWin* window) cons_remove_alert(ProfWin* window)
{ {
char* win_name = win_to_string(window); auto_char char* win_name = win_to_string(window);
GList* item = g_list_find_custom(alert_list, win_name, (GCompareFunc)g_strcmp0); GList* item = g_list_find_custom(alert_list, win_name, (GCompareFunc)g_strcmp0);
alert_list = g_list_remove_link(alert_list, item); alert_list = g_list_remove_link(alert_list, item);
g_list_free_full(item, g_free); g_list_free_full(item, g_free);
free(win_name);
} }
void void

View File

@ -234,8 +234,6 @@ ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity)
// show nothing // show nothing
if (g_strcmp0(p_contact_subscription(contact), "none") == 0) { if (g_strcmp0(p_contact_subscription(contact), "none") == 0) {
free(show_console);
free(show_chat_win);
return; return;
} }
@ -697,9 +695,8 @@ ui_focus_win(ProfWin* window)
} }
status_bar_current(i); status_bar_current(i);
char* identifier = win_get_tab_identifier(window); auto_char char* identifier = win_get_tab_identifier(window);
status_bar_active(i, window->type, identifier); status_bar_active(i, window->type, identifier);
free(identifier);
} }
void void

View File

@ -652,33 +652,30 @@ _inp_rl_tab_com_handler(int count, int key, gboolean previous)
if (strncmp(rl_line_buffer, "/", 1) == 0) { if (strncmp(rl_line_buffer, "/", 1) == 0) {
ProfWin* window = wins_get_current(); ProfWin* window = wins_get_current();
char* result = cmd_ac_complete(window, rl_line_buffer, previous); auto_char char* result = cmd_ac_complete(window, rl_line_buffer, previous);
if (result) { if (result) {
rl_replace_line(result, 1); rl_replace_line(result, 1);
rl_point = rl_end; rl_point = rl_end;
free(result);
return 0; return 0;
} }
} }
if (strncmp(rl_line_buffer, ">", 1) == 0) { if (strncmp(rl_line_buffer, ">", 1) == 0) {
ProfWin* window = wins_get_current(); ProfWin* window = wins_get_current();
char* result = win_quote_autocomplete(window, rl_line_buffer, previous); auto_char char* result = win_quote_autocomplete(window, rl_line_buffer, previous);
if (result) { if (result) {
rl_replace_line(result, 1); rl_replace_line(result, 1);
rl_point = rl_end; rl_point = rl_end;
free(result);
return 0; return 0;
} }
} }
ProfWin* current = wins_get_current(); ProfWin* current = wins_get_current();
if (current->type == WIN_MUC) { if (current->type == WIN_MUC) {
char* result = muc_autocomplete(current, rl_line_buffer, previous); auto_char char* result = muc_autocomplete(current, rl_line_buffer, previous);
if (result) { if (result) {
rl_replace_line(result, 1); rl_replace_line(result, 1);
rl_point = rl_end; rl_point = rl_end;
free(result);
} }
} }

View File

@ -515,7 +515,7 @@ mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* c
char* mynick = muc_nick(mucwin->roomjid); char* mynick = muc_nick(mucwin->roomjid);
// displayed message char // displayed message char
char* ch; auto_char char* ch;
if (mucwin->message_char) { if (mucwin->message_char) {
ch = strdup(mucwin->message_char); ch = strdup(mucwin->message_char);
} else if (enc_mode == PROF_MSG_ENC_OTR) { } else if (enc_mode == PROF_MSG_ENC_OTR) {
@ -531,7 +531,6 @@ mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* c
} }
win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message); win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message);
free(ch);
// save last id and message for LMC // save last id and message for LMC
if (id) { if (id) {
@ -564,7 +563,7 @@ mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList
ProfWin* window = (ProfWin*)mucwin; ProfWin* window = (ProfWin*)mucwin;
char* mynick = muc_nick(mucwin->roomjid); char* mynick = muc_nick(mucwin->roomjid);
char* ch; auto_char char* ch;
if (mucwin->message_char) { if (mucwin->message_char) {
ch = strdup(mucwin->message_char); ch = strdup(mucwin->message_char);
} else if (message->enc == PROF_MSG_ENC_OTR) { } else if (message->enc == PROF_MSG_ENC_OTR) {
@ -589,8 +588,6 @@ mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList
} else { } else {
win_println_incoming_muc_msg(window, ch, flags, message); win_println_incoming_muc_msg(window, ch, flags, message);
} }
free(ch);
} }
void void

View File

@ -255,7 +255,7 @@ notify(const char* const message, int timeout, const char* const category)
#ifdef HAVE_OSXNOTIFY #ifdef HAVE_OSXNOTIFY
GString* notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '"); GString* notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '");
char* escaped_single = str_replace(message, "'", "'\\''"); auto_char char* escaped_single = str_replace(message, "'", "'\\''");
if (escaped_single[0] == '<') { if (escaped_single[0] == '<') {
g_string_append(notify_command, "\\<"); g_string_append(notify_command, "\\<");
@ -274,7 +274,6 @@ notify(const char* const message, int timeout, const char* const category)
} }
g_string_append(notify_command, "'"); g_string_append(notify_command, "'");
free(escaped_single);
char* term_name = getenv("TERM_PROGRAM"); char* term_name = getenv("TERM_PROGRAM");
char* app_id = NULL; char* app_id = NULL;

View File

@ -77,10 +77,9 @@ _occuptantswin_occupant(ProfLayoutSplit* layout, GList* item, gboolean showjid,
GString* msg = g_string_new(spaces->str); GString* msg = g_string_new(spaces->str);
char* ch = prefs_get_occupants_char(); auto_char char* ch = prefs_get_occupants_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%s", ch); g_string_append_printf(msg, "%s", ch);
free(ch);
} }
gboolean wrap = prefs_get_boolean(PREF_OCCUPANTS_WRAP); gboolean wrap = prefs_get_boolean(PREF_OCCUPANTS_WRAP);
@ -131,10 +130,9 @@ occupantswin_occupants(const char* const roomjid)
GString* prefix = g_string_new(" "); GString* prefix = g_string_new(" ");
char* ch = prefs_get_occupants_header_char(); auto_char char* ch = prefs_get_occupants_header_char();
if (ch) { if (ch) {
g_string_append_printf(prefix, "%s", ch); g_string_append_printf(prefix, "%s", ch);
free(ch);
} }
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {

View File

@ -307,10 +307,9 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin)
indent--; indent--;
} }
} }
char* ch = prefs_get_roster_contact_char(); auto_char char* ch = prefs_get_roster_contact_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%s", ch); g_string_append_printf(msg, "%s", ch);
free(ch);
} }
auto_gchar gchar* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); auto_gchar gchar* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
@ -369,10 +368,9 @@ _rosterwin_contact(ProfLayoutSplit* layout, PContact contact)
indent--; indent--;
} }
} }
char* ch = prefs_get_roster_contact_char(); auto_char char* ch = prefs_get_roster_contact_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%s", ch); g_string_append_printf(msg, "%s", ch);
free(ch);
} }
auto_gchar gchar* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); auto_gchar gchar* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
@ -519,10 +517,9 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
wattron(layout->subwin, theme_attrs(resource_presence_colour)); wattron(layout->subwin, theme_attrs(resource_presence_colour));
GString* msg = g_string_new(""); GString* msg = g_string_new("");
char* ch = prefs_get_roster_resource_char(); auto_char char* ch = prefs_get_roster_resource_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%s", ch); g_string_append_printf(msg, "%s", ch);
free(ch);
} else { } else {
g_string_append(msg, " "); g_string_append(msg, " ");
} }
@ -581,10 +578,9 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
g_string_append(msg, " "); g_string_append(msg, " ");
this_indent--; this_indent--;
} }
char* ch = prefs_get_roster_resource_char(); auto_char char* ch = prefs_get_roster_resource_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%s", ch); g_string_append_printf(msg, "%s", ch);
free(ch);
} }
g_string_append(msg, resource->name); g_string_append(msg, resource->name);
if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) { if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) {
@ -741,10 +737,9 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
indent--; indent--;
} }
} }
char* ch = prefs_get_roster_room_char(); auto_char char* ch = prefs_get_roster_room_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%s", ch); g_string_append_printf(msg, "%s", ch);
free(ch);
} }
auto_gchar gchar* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); auto_gchar gchar* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD);
@ -838,10 +833,9 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
g_string_append_printf(privmsg, "(%d) ", privwin->unread); g_string_append_printf(privmsg, "(%d) ", privwin->unread);
} }
ch = prefs_get_roster_room_private_char(); auto_char char* ch2 = prefs_get_roster_room_private_char();
if (ch) { if (ch2) {
g_string_append_printf(privmsg, "%s", ch); g_string_append_printf(privmsg, "%s", ch2);
free(ch);
} }
char* nick = privwin->fulljid + strlen(mucwin->roomjid) + 1; char* nick = privwin->fulljid + strlen(mucwin->roomjid) + 1;
@ -930,10 +924,9 @@ _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats)
g_string_append_printf(privmsg, "(%d) ", privwin->unread); g_string_append_printf(privmsg, "(%d) ", privwin->unread);
} }
char* ch = prefs_get_roster_private_char(); auto_char char* ch = prefs_get_roster_private_char();
if (ch) { if (ch) {
g_string_append_printf(privmsg, "%s", ch); g_string_append_printf(privmsg, "%s", ch);
free(ch);
} }
g_string_append(privmsg, privwin->fulljid); g_string_append(privmsg, privwin->fulljid);
@ -1011,10 +1004,9 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins)
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
GString* header = g_string_new(" "); GString* header = g_string_new(" ");
char* ch = prefs_get_roster_header_char(); auto_char char* ch = prefs_get_roster_header_char();
if (ch) { if (ch) {
g_string_append_printf(header, "%s", ch); g_string_append_printf(header, "%s", ch);
free(ch);
} }
g_string_append(header, "Unsubscribed"); g_string_append(header, "Unsubscribed");
@ -1057,10 +1049,9 @@ _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSL
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
GString* header = g_string_new(" "); GString* header = g_string_new(" ");
char* ch = prefs_get_roster_header_char(); auto_char char* ch = prefs_get_roster_header_char();
if (ch) { if (ch) {
g_string_append_printf(header, "%s", ch); g_string_append_printf(header, "%s", ch);
free(ch);
} }
g_string_append(header, title); g_string_append(header, title);
@ -1108,10 +1099,9 @@ _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title)
{ {
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
GString* header = g_string_new(" "); GString* header = g_string_new(" ");
char* ch = prefs_get_roster_header_char(); auto_char char* ch = prefs_get_roster_header_char();
if (ch) { if (ch) {
g_string_append_printf(header, "%s", ch); g_string_append_printf(header, "%s", ch);
free(ch);
} }
g_string_append(header, title); g_string_append(header, title);
@ -1170,10 +1160,9 @@ _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs)
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
GString* title_str = g_string_new(" "); GString* title_str = g_string_new(" ");
char* ch = prefs_get_roster_header_char(); auto_char char* ch = prefs_get_roster_header_char();
if (ch) { if (ch) {
g_string_append_printf(title_str, "%s", ch); g_string_append_printf(title_str, "%s", ch);
free(ch);
} }
g_string_append(title_str, "Private chats"); g_string_append(title_str, "Private chats");

View File

@ -433,10 +433,9 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num)
pos++; pos++;
} }
if (show_name) { if (show_name) {
char* display_name = _display_name(tab); auto_char char* display_name = _display_name(tab);
mvwprintw(statusbar_win, 0, pos, "%s", display_name); mvwprintw(statusbar_win, 0, pos, "%s", display_name);
pos += utf8_display_len(display_name); pos += utf8_display_len(display_name);
free(display_name);
} }
wattroff(statusbar_win, status_attrs); wattroff(statusbar_win, status_attrs);
@ -606,10 +605,9 @@ _tabs_width(void)
if (!show_read && !is_current && !tab->highlight) if (!show_read && !is_current && !tab->highlight)
continue; continue;
char* display_name = _display_name(tab); auto_char char* display_name = _display_name(tab);
width += utf8_display_len(display_name); width += utf8_display_len(display_name);
width += 4; width += 4;
free(display_name);
} }
} }
return width; return width;
@ -625,10 +623,9 @@ _tabs_width(void)
if (!show_read && !is_current && !tab->highlight) if (!show_read && !is_current && !tab->highlight)
continue; continue;
char* display_name = _display_name(tab); auto_char char* display_name = _display_name(tab);
width += utf8_display_len(display_name); width += utf8_display_len(display_name);
width += 2; width += 2;
free(display_name);
} }
} }
return width; return width;
@ -710,10 +707,9 @@ _display_name(StatusBarTab* tab)
return fullname; return fullname;
} }
gchar* trimmed = g_utf8_substring(fullname, 0, tablen); auto_gchar gchar* trimmed = g_utf8_substring(fullname, 0, tablen);
free(fullname);
char* trimmedname = strdup(trimmed); char* trimmedname = strdup(trimmed);
g_free(trimmed); free(fullname);
return trimmedname; return trimmedname;
} }

View File

@ -195,13 +195,11 @@ _title_bar_draw(void)
waddch(win, ' '); waddch(win, ' ');
} }
char* title = win_get_title(current); auto_char char* title = win_get_title(current);
mvwprintw(win, 0, 0, " %s", title); mvwprintw(win, 0, 0, " %s", title);
pos = strlen(title) + 1; pos = strlen(title) + 1;
free(title);
// presence is written from the right side // presence is written from the right side
// calculate it first so we have a maxposition // calculate it first so we have a maxposition
maxrightpos = _calc_self_presence(); maxrightpos = _calc_self_presence();

View File

@ -53,14 +53,13 @@ char*
vcardwin_get_string(ProfVcardWin* vcardwin) vcardwin_get_string(ProfVcardWin* vcardwin)
{ {
GString* string = g_string_new("vCard: "); GString* string = g_string_new("vCard: ");
char* jid = connection_get_barejid(); auto_char char* jid = connection_get_barejid();
g_string_append(string, jid); g_string_append(string, jid);
if (vcardwin->vcard && vcardwin->vcard->modified) { if (vcardwin->vcard && vcardwin->vcard->modified) {
g_string_append(string, " (modified)"); g_string_append(string, " (modified)");
} }
free(jid);
return g_string_free(string, FALSE); return g_string_free(string, FALSE);
} }

View File

@ -387,7 +387,7 @@ win_get_title(ProfWin* window)
assert(vcardwin->memcheck == PROFVCARDWIN_MEMCHECK); assert(vcardwin->memcheck == PROFVCARDWIN_MEMCHECK);
GString* title = g_string_new("vCard "); GString* title = g_string_new("vCard ");
char* jid = connection_get_barejid(); auto_char char* jid = connection_get_barejid();
g_string_append(title, jid); g_string_append(title, jid);
@ -395,7 +395,6 @@ win_get_title(ProfWin* window)
g_string_append(title, " *"); g_string_append(title, " *");
} }
free(jid);
return g_string_free(title, FALSE); return g_string_free(title, FALSE);
} }
} }
@ -1207,11 +1206,10 @@ win_show_vcard(ProfWin* window, vCard* vcard)
case VCARD_BIRTHDAY: case VCARD_BIRTHDAY:
{ {
auto_gchar gchar* date_format = prefs_get_string(PREF_TIME_VCARD); auto_gchar gchar* date_format = prefs_get_string(PREF_TIME_VCARD);
gchar* date = g_date_time_format(element->birthday, date_format); auto_gchar gchar* date = g_date_time_format(element->birthday, date_format);
assert(date != NULL); assert(date != NULL);
win_println(window, THEME_DEFAULT, "!", "[%d] Birthday: %s", index, date); win_println(window, THEME_DEFAULT, "!", "[%d] Birthday: %s", index, date);
g_free(date);
break; break;
} }
case VCARD_ADDRESS: case VCARD_ADDRESS:
@ -1336,14 +1334,12 @@ win_show_status_string(ProfWin* window, const char* const from,
win_append(window, presence_colour, " is %s", default_show); win_append(window, presence_colour, " is %s", default_show);
if (last_activity) { if (last_activity) {
gchar* date_fmt = NULL; auto_gchar gchar* date_fmt = NULL;
auto_gchar gchar* time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); auto_gchar gchar* time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY);
date_fmt = g_date_time_format(last_activity, time_pref); date_fmt = g_date_time_format(last_activity, time_pref);
assert(date_fmt != NULL); assert(date_fmt != NULL);
win_append(window, presence_colour, ", last activity: %s", date_fmt); win_append(window, presence_colour, ", last activity: %s", date_fmt);
g_free(date_fmt);
} }
if (status) if (status)
@ -1406,7 +1402,7 @@ win_print_incoming(ProfWin* window, const char* const display_name_from, ProfMes
switch (window->type) { switch (window->type) {
case WIN_CHAT: case WIN_CHAT:
{ {
char* enc_char; auto_char char* enc_char;
ProfChatWin* chatwin = (ProfChatWin*)window; ProfChatWin* chatwin = (ProfChatWin*)window;
if (chatwin->incoming_char) { if (chatwin->incoming_char) {
@ -1431,8 +1427,6 @@ win_print_incoming(ProfWin* window, const char* const display_name_from, ProfMes
_win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain);
} }
} }
free(enc_char);
break; break;
} }
case WIN_PRIVATE: case WIN_PRIVATE:
@ -1926,7 +1920,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
{ {
int starty = getcury(win); int starty = getcury(win);
int wordi = 0; int wordi = 0;
char* word = malloc(strlen(message) + 1); auto_char char* word = malloc(strlen(message) + 1);
gchar* curr_ch = g_utf8_offset_to_pointer(message, 0); gchar* curr_ch = g_utf8_offset_to_pointer(message, 0);
@ -2033,8 +2027,6 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
curr_ch = g_utf8_next_char(curr_ch); curr_ch = g_utf8_next_char(curr_ch);
} }
} }
free(word);
} }
void void

View File

@ -949,13 +949,12 @@ wins_swap(int source_win, int target_win)
g_hash_table_steal(windows, GINT_TO_POINTER(source_win)); g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
status_bar_inactive(source_win); status_bar_inactive(source_win);
char* identifier = win_get_tab_identifier(source); auto_char char* identifier = win_get_tab_identifier(source);
if (win_unread(source) > 0) { if (win_unread(source) > 0) {
status_bar_new(target_win, source->type, identifier); status_bar_new(target_win, source->type, identifier);
} else { } else {
status_bar_active(target_win, source->type, identifier); status_bar_active(target_win, source->type, identifier);
} }
free(identifier);
if (wins_get_current_num() == source_win) { if (wins_get_current_num() == source_win) {
wins_set_current_by_num(target_win); wins_set_current_by_num(target_win);
ui_focus_win(console); ui_focus_win(console);
@ -967,8 +966,8 @@ wins_swap(int source_win, int target_win)
g_hash_table_steal(windows, GINT_TO_POINTER(target_win)); g_hash_table_steal(windows, GINT_TO_POINTER(target_win));
g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target); g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target);
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
char* source_identifier = win_get_tab_identifier(source); auto_char char* source_identifier = win_get_tab_identifier(source);
char* target_identifier = win_get_tab_identifier(target); auto_char char* target_identifier = win_get_tab_identifier(target);
if (win_unread(source) > 0) { if (win_unread(source) > 0) {
status_bar_new(target_win, source->type, source_identifier); status_bar_new(target_win, source->type, source_identifier);
} else { } else {
@ -979,8 +978,6 @@ wins_swap(int source_win, int target_win)
} else { } else {
status_bar_active(source_win, target->type, target_identifier); status_bar_active(source_win, target->type, target_identifier);
} }
free(source_identifier);
free(target_identifier);
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) { if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
ui_focus_win(console); ui_focus_win(console);
} }
@ -1088,7 +1085,7 @@ wins_tidy(void)
GList* curr = keys; GList* curr = keys;
while (curr) { while (curr) {
ProfWin* window = g_hash_table_lookup(windows, curr->data); ProfWin* window = g_hash_table_lookup(windows, curr->data);
char* identifier = win_get_tab_identifier(window); auto_char char* identifier = win_get_tab_identifier(window);
g_hash_table_steal(windows, curr->data); g_hash_table_steal(windows, curr->data);
if (num == 10) { if (num == 10) {
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window); g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
@ -1105,7 +1102,6 @@ wins_tidy(void)
status_bar_active(num, window->type, identifier); status_bar_active(num, window->type, identifier);
} }
} }
free(identifier);
num++; num++;
curr = g_list_next(curr); curr = g_list_next(curr);
} }
@ -1142,14 +1138,13 @@ wins_create_summary(gboolean unread)
GString* line = g_string_new(""); GString* line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data); int ui_index = GPOINTER_TO_INT(curr->data);
char* winstring = win_to_string(window); auto_char char* winstring = win_to_string(window);
if (!winstring) { if (!winstring) {
g_string_free(line, TRUE); g_string_free(line, TRUE);
continue; continue;
} }
g_string_append_printf(line, "%d: %s", ui_index, winstring); g_string_append_printf(line, "%d: %s", ui_index, winstring);
free(winstring);
result = g_slist_append(result, strdup(line->str)); result = g_slist_append(result, strdup(line->str));
g_string_free(line, TRUE); g_string_free(line, TRUE);
@ -1188,14 +1183,13 @@ wins_create_summary_attention()
GString* line = g_string_new(""); GString* line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data); int ui_index = GPOINTER_TO_INT(curr->data);
char* winstring = win_to_string(window); auto_char char* winstring = win_to_string(window);
if (!winstring) { if (!winstring) {
g_string_free(line, TRUE); g_string_free(line, TRUE);
continue; continue;
} }
g_string_append_printf(line, "%d: %s", ui_index, winstring); g_string_append_printf(line, "%d: %s", ui_index, winstring);
free(winstring);
result = g_slist_append(result, strdup(line->str)); result = g_slist_append(result, strdup(line->str));
g_string_free(line, TRUE); g_string_free(line, TRUE);

View File

@ -100,7 +100,7 @@ avatar_pep_subscribe(void)
gboolean gboolean
avatar_set(const char* path) avatar_set(const char* path)
{ {
char* expanded_path = get_expanded_path(path); auto_char char* expanded_path = get_expanded_path(path);
GError* err = NULL; GError* err = NULL;
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(expanded_path, &err); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(expanded_path, &err);
@ -109,7 +109,6 @@ avatar_set(const char* path)
cons_show_error("An error occurred while opening %s: %s.", expanded_path, err ? err->message : "No error message given"); cons_show_error("An error occurred while opening %s: %s.", expanded_path, err ? err->message : "No error message given");
return FALSE; return FALSE;
} }
free(expanded_path);
// Scale img // Scale img
int w = gdk_pixbuf_get_width(pixbuf); int w = gdk_pixbuf_get_width(pixbuf);
@ -127,7 +126,7 @@ avatar_set(const char* path)
pixbuf = new_pixbuf; pixbuf = new_pixbuf;
} }
gchar* img_data; auto_gchar gchar* img_data;
gsize len = -1; gsize len = -1;
if (!gdk_pixbuf_save_to_buffer(pixbuf, &img_data, &len, "png", &err, NULL)) { if (!gdk_pixbuf_save_to_buffer(pixbuf, &img_data, &len, "png", &err, NULL)) {
@ -141,7 +140,6 @@ avatar_set(const char* path)
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
iq = stanza_create_avatar_metadata_publish_iq(ctx, img_data, len, gdk_pixbuf_get_height(pixbuf), gdk_pixbuf_get_width(pixbuf)); iq = stanza_create_avatar_metadata_publish_iq(ctx, img_data, len, gdk_pixbuf_get_height(pixbuf), gdk_pixbuf_get_width(pixbuf));
free(img_data);
g_object_unref(pixbuf); g_object_unref(pixbuf);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
@ -252,13 +250,11 @@ _avatar_request_item_by_id(const char* jid, avatar_metadata* data)
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* uid = connection_create_stanza_id(); auto_char char* uid = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid); xmpp_stanza_t* iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid);
iq_id_handler_add(uid, _avatar_request_item_result_handler, (ProfIqFreeCallback)_free_avatar_data, data); iq_id_handler_add(uid, _avatar_request_item_result_handler, (ProfIqFreeCallback)_free_avatar_data, data);
free(uid);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -297,18 +293,16 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
return 1; return 1;
} }
char* buf = xmpp_stanza_get_text(st_data); auto_char char* buf = xmpp_stanza_get_text(st_data);
if (!buf) { if (!buf) {
return 1; return 1;
} }
gsize size; gsize size;
gchar* de = (gchar*)g_base64_decode(buf, &size); auto_gchar gchar* de = (gchar*)g_base64_decode(buf, &size);
free(buf);
char* path = files_get_data_path(""); auto_gchar gchar* path = files_get_data_path("");
GString* filename = g_string_new(path); GString* filename = g_string_new(path);
free(path);
g_string_append(filename, "avatars/"); g_string_append(filename, "avatars/");
@ -323,7 +317,7 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
} }
} }
gchar* from = str_replace(from_attr, "@", "_at_"); auto_gchar gchar* from = str_replace(from_attr, "@", "_at_");
g_string_append(filename, from); g_string_append(filename, from);
avatar_metadata* data = (avatar_metadata*)userdata; avatar_metadata* data = (avatar_metadata*)userdata;
@ -340,8 +334,6 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
g_string_append(filename, ".webp"); g_string_append(filename, ".webp");
} }
free(from);
GError* err = NULL; GError* err = NULL;
if (g_file_set_contents(filename->str, de, size, &err) == FALSE) { if (g_file_set_contents(filename->str, de, size, &err) == FALSE) {
log_error("Unable to save picture: %s", err->message); log_error("Unable to save picture: %s", err->message);
@ -371,7 +363,6 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
} }
g_string_free(filename, TRUE); g_string_free(filename, TRUE);
free(de);
return 1; return 1;
} }

View File

@ -70,13 +70,12 @@ blocking_request(void)
} }
blocked_ac = autocomplete_new(); blocked_ac = autocomplete_new();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
iq_id_handler_add(id, _blocklist_result_handler, NULL, NULL); iq_id_handler_add(id, _blocklist_result_handler, NULL, NULL);
xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_ctx_t* ctx = connection_get_ctx();
xmpp_stanza_t* iq = stanza_create_blocked_list_request(ctx); xmpp_stanza_t* iq = stanza_create_blocked_list_request(ctx);
xmpp_stanza_set_id(iq, id); xmpp_stanza_set_id(iq, id);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
@ -112,7 +111,7 @@ blocked_add(char* jid, blocked_report reportkind, const char* const message)
xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_ctx_t* ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_t* block = xmpp_stanza_new(ctx); xmpp_stanza_t* block = xmpp_stanza_new(ctx);
@ -156,7 +155,6 @@ blocked_add(char* jid, blocked_report reportkind, const char* const message)
xmpp_stanza_release(block); xmpp_stanza_release(block);
iq_id_handler_add(id, _block_add_result_handler, free, strdup(jid)); iq_id_handler_add(id, _block_add_result_handler, free, strdup(jid));
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
@ -174,7 +172,7 @@ blocked_remove(char* jid)
xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_ctx_t* ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_t* block = xmpp_stanza_new(ctx); xmpp_stanza_t* block = xmpp_stanza_new(ctx);
@ -192,7 +190,6 @@ blocked_remove(char* jid)
xmpp_stanza_release(block); xmpp_stanza_release(block);
iq_id_handler_add(id, _block_remove_result_handler, free, strdup(jid)); iq_id_handler_add(id, _block_remove_result_handler, free, strdup(jid));
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);

View File

@ -312,13 +312,12 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
int minimize = 0; int minimize = 0;
xmpp_stanza_t* minimize_st = xmpp_stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS); xmpp_stanza_t* minimize_st = xmpp_stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS);
if (minimize_st) { if (minimize_st) {
char* min_str = xmpp_stanza_get_text(minimize_st); auto_char char* min_str = xmpp_stanza_get_text(minimize_st);
if (strcmp(min_str, "true") == 0) { if (strcmp(min_str, "true") == 0) {
minimize = 1; minimize = 1;
} else if (strcmp(min_str, "false") == 0) { } else if (strcmp(min_str, "false") == 0) {
minimize = 2; minimize = 2;
} }
free(min_str);
} }
autocomplete_add(bookmark_ac, barejid); autocomplete_add(bookmark_ac, barejid);
@ -364,9 +363,8 @@ _send_bookmarks(void)
{ {
xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_ctx_t* ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);

View File

@ -58,7 +58,7 @@
#include "xmpp/form.h" #include "xmpp/form.h"
#include "xmpp/capabilities.h" #include "xmpp/capabilities.h"
static char* cache_loc; static gchar* cache_loc;
static GKeyFile* cache; static GKeyFile* cache;
static GHashTable* jid_to_ver; static GHashTable* jid_to_ver;
@ -355,7 +355,7 @@ caps_close(void)
cache = NULL; cache = NULL;
g_hash_table_destroy(jid_to_ver); g_hash_table_destroy(jid_to_ver);
g_hash_table_destroy(jid_to_caps); g_hash_table_destroy(jid_to_caps);
free(cache_loc); g_free(cache_loc);
cache_loc = NULL; cache_loc = NULL;
g_hash_table_destroy(prof_features); g_hash_table_destroy(prof_features);
prof_features = NULL; prof_features = NULL;

View File

@ -238,10 +238,9 @@ _conn_apply_settings(const char* const jid, const char* const passwd, const char
return FALSE; return FALSE;
} }
char* cert_path = prefs_get_tls_certpath(); auto_char char* cert_path = prefs_get_tls_certpath();
if (cert_path) { if (cert_path) {
xmpp_conn_set_capath(conn.xmpp_conn, cert_path); xmpp_conn_set_capath(conn.xmpp_conn, cert_path);
free(cert_path);
} }
xmpp_conn_set_certfail_handler(conn.xmpp_conn, _connection_certfail_cb); xmpp_conn_set_certfail_handler(conn.xmpp_conn, _connection_certfail_cb);
@ -734,9 +733,8 @@ connection_get_barejid(void)
if (!jid) if (!jid)
return NULL; return NULL;
Jid* jidp = jid_create(jid); auto_jid Jid* jidp = jid_create(jid);
char* result = strdup(jidp->barejid); char* result = strdup(jidp->barejid);
jid_destroy(jidp);
return result; return result;
} }
@ -811,18 +809,15 @@ connection_free_uuid(char* uuid)
char* char*
connection_create_stanza_id(void) connection_create_stanza_id(void)
{ {
char* rndid = get_random_string(CON_RAND_ID_LEN); auto_char char* rndid = get_random_string(CON_RAND_ID_LEN);
assert(rndid != NULL); assert(rndid != NULL);
gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA1, auto_gchar gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA1,
(guchar*)prof_identifier, strlen(prof_identifier), (guchar*)prof_identifier, strlen(prof_identifier),
rndid, strlen(rndid)); rndid, strlen(rndid));
char* ret = g_strdup_printf("%s%s", rndid, hmac); char* ret = g_strdup_printf("%s%s", rndid, hmac);
free(rndid);
g_free(hmac);
return ret; return ret;
} }
@ -1108,11 +1103,9 @@ _xmpp_file_logger(void* const userdata, const xmpp_log_level_t xmpp_level, const
static void static void
_random_bytes_init(void) _random_bytes_init(void)
{ {
char* rndbytes_loc; auto_gchar gchar* rndbytes_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER);
GKeyFile* rndbytes; GKeyFile* rndbytes;
rndbytes_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER);
if (g_file_test(rndbytes_loc, G_FILE_TEST_EXISTS)) { if (g_file_test(rndbytes_loc, G_FILE_TEST_EXISTS)) {
g_chmod(rndbytes_loc, S_IRUSR | S_IWUSR); g_chmod(rndbytes_loc, S_IRUSR | S_IWUSR);
} }
@ -1127,18 +1120,13 @@ _random_bytes_init(void)
g_key_file_set_string(rndbytes, "identifier", "random_bytes", profanity_instance_id); g_key_file_set_string(rndbytes, "identifier", "random_bytes", profanity_instance_id);
gsize g_data_size; gsize g_data_size;
gchar* g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL); auto_gchar gchar* g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL);
gchar* base = g_path_get_dirname(rndbytes_loc); auto_gchar gchar* base = g_path_get_dirname(rndbytes_loc);
gchar* true_loc = get_file_or_linked(rndbytes_loc, base); auto_gchar gchar* true_loc = get_file_or_linked(rndbytes_loc, base);
g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);
g_free(base);
free(true_loc);
g_free(g_accounts_data);
} }
free(rndbytes_loc);
g_key_file_free(rndbytes); g_key_file_free(rndbytes);
} }

View File

@ -429,10 +429,9 @@ iq_http_upload_request(HTTPUpload* upload)
} }
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_http_upload_request(ctx, id, jid, upload); xmpp_stanza_t* iq = stanza_create_http_upload_request(ctx, id, jid, upload);
iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload); iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
@ -444,13 +443,11 @@ void
iq_disco_info_request(gchar* jid) iq_disco_info_request(gchar* jid)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL);
iq_id_handler_add(id, _disco_info_response_id_handler, NULL, NULL); iq_id_handler_add(id, _disco_info_response_id_handler, NULL, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -459,13 +456,11 @@ void
iq_disco_info_request_onconnect(gchar* jid) iq_disco_info_request_onconnect(gchar* jid)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL);
iq_id_handler_add(id, _disco_info_response_id_handler_onconnect, NULL, NULL); iq_id_handler_add(id, _disco_info_response_id_handler_onconnect, NULL, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -474,13 +469,11 @@ void
iq_last_activity_request(gchar* jid) iq_last_activity_request(gchar* jid)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_last_activity_iq(ctx, id, jid); xmpp_stanza_t* iq = stanza_create_last_activity_iq(ctx, id, jid);
iq_id_handler_add(id, _last_activity_response_id_handler, NULL, NULL); iq_id_handler_add(id, _last_activity_response_id_handler, NULL, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -489,7 +482,7 @@ void
iq_room_info_request(const char* const room, gboolean display_result) iq_room_info_request(const char* const room, gboolean display_result)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, room, NULL); xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, room, NULL);
ProfRoomInfoData* cb_data = malloc(sizeof(ProfRoomInfoData)); ProfRoomInfoData* cb_data = malloc(sizeof(ProfRoomInfoData));
@ -502,8 +495,6 @@ iq_room_info_request(const char* const room, gboolean display_result)
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
free(id);
} }
void void
@ -832,7 +823,7 @@ static void
_error_handler(xmpp_stanza_t* const stanza) _error_handler(xmpp_stanza_t* const stanza)
{ {
const char* id = xmpp_stanza_get_id(stanza); const char* id = xmpp_stanza_get_id(stanza);
char* error_msg = stanza_get_error_message(stanza); auto_char char* error_msg = stanza_get_error_message(stanza);
if (id) { if (id) {
log_debug("IQ error handler fired, id: %s, error: %s", id, error_msg); log_debug("IQ error handler fired, id: %s, error: %s", id, error_msg);
@ -841,8 +832,6 @@ _error_handler(xmpp_stanza_t* const stanza)
log_debug("IQ error handler fired, error: %s", error_msg); log_debug("IQ error handler fired, error: %s", error_msg);
log_error("IQ error received, error: %s", error_msg); log_error("IQ error received, error: %s", error_msg);
} }
free(error_msg);
} }
static int static int
@ -871,9 +860,8 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_warning("Error received for capabilities response from %s: ", from, error_message); log_warning("Error received for capabilities response from %s: ", from, error_message);
free(error_message);
return 0; return 0;
} }
@ -950,9 +938,8 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userd
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_warning("Error received for capabilities response from %s: ", from, error_message); log_warning("Error received for capabilities response from %s: ", from, error_message);
free(error_message);
return 0; return 0;
} }
@ -1009,9 +996,8 @@ _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userda
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_warning("Error received for capabilities response from %s: ", from, error_message); log_warning("Error received for capabilities response from %s: ", from, error_message);
free(error_message);
return 0; return 0;
} }
@ -1142,7 +1128,7 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
{ {
const char* id = xmpp_stanza_get_id(stanza); const char* id = xmpp_stanza_get_id(stanza);
const char* type = xmpp_stanza_get_type(stanza); const char* type = xmpp_stanza_get_type(stanza);
char* from = strdup(xmpp_stanza_get_from(stanza)); auto_char char* from = strdup(xmpp_stanza_get_from(stanza));
if (id) { if (id) {
log_debug("IQ command list result handler fired, id: %s.", id); log_debug("IQ command list result handler fired, id: %s.", id);
@ -1152,14 +1138,12 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_debug("Error retrieving command list for %s: %s", from, error_message); log_debug("Error retrieving command list for %s: %s", from, error_message);
ProfWin* win = wins_get_by_string(from); ProfWin* win = wins_get_by_string(from);
if (win) { if (win) {
win_command_list_error(win, error_message); win_command_list_error(win, error_message);
} }
free(error_message);
free(from);
return 0; return 0;
} }
@ -1187,7 +1171,6 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
win_handle_command_list(win, cmds); win_handle_command_list(win, cmds);
g_slist_free(cmds); g_slist_free(cmds);
free(from);
return 0; return 0;
} }
@ -1215,10 +1198,9 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_debug("Error executing command %s for %s: %s", command, from, error_message); log_debug("Error executing command %s for %s: %s", command, from, error_message);
win_command_exec_error(win, command, error_message); win_command_exec_error(win, command, error_message);
free(error_message);
return 0; return 0;
} }
@ -1321,10 +1303,9 @@ _enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
{ {
const char* type = xmpp_stanza_get_type(stanza); const char* type = xmpp_stanza_get_type(stanza);
if (g_strcmp0(type, "error") == 0) { if (g_strcmp0(type, "error") == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
cons_show_error("Server error enabling message carbons: %s", error_message); cons_show_error("Server error enabling message carbons: %s", error_message);
log_debug("Error enabling carbons: %s", error_message); log_debug("Error enabling carbons: %s", error_message);
free(error_message);
} else { } else {
log_debug("Message carbons enabled."); log_debug("Message carbons enabled.");
} }
@ -1337,10 +1318,9 @@ _disable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
{ {
const char* type = xmpp_stanza_get_type(stanza); const char* type = xmpp_stanza_get_type(stanza);
if (g_strcmp0(type, "error") == 0) { if (g_strcmp0(type, "error") == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
cons_show_error("Server error disabling message carbons: %s", error_message); cons_show_error("Server error disabling message carbons: %s", error_message);
log_debug("Error disabling carbons: %s", error_message); log_debug("Error disabling carbons: %s", error_message);
free(error_message);
} else { } else {
log_debug("Message carbons disabled."); log_debug("Message carbons disabled.");
} }
@ -1357,14 +1337,13 @@ _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
if (!error_message) { if (!error_message) {
cons_show_error("Error returned from pinging %s.", from); cons_show_error("Error returned from pinging %s.", from);
} else { } else {
cons_show_error("Error returned from pinging %s: %s.", from, error_message); cons_show_error("Error returned from pinging %s: %s.", from, error_message);
} }
free(error_message);
return 0; return 0;
} }
@ -1444,9 +1423,8 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
} }
// show warning if error // show warning if error
char* error_msg = stanza_get_error_message(stanza); auto_char char* error_msg = stanza_get_error_message(stanza);
log_warning("Server ping (id=%s) responded with error: %s", id, error_msg); log_warning("Server ping (id=%s) responded with error: %s", id, error_msg);
free(error_msg);
// turn off autoping if error type is 'cancel' // turn off autoping if error type is 'cancel'
xmpp_stanza_t* error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); xmpp_stanza_t* error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
@ -1483,9 +1461,8 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
if (g_strcmp0(type, STANZA_TYPE_RESULT) != 0) { if (g_strcmp0(type, STANZA_TYPE_RESULT) != 0) {
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
ui_handle_software_version_error(from, error_message); ui_handle_software_version_error(from, error_message);
free(error_message);
} else { } else {
ui_handle_software_version_error(from, "unknown error"); ui_handle_software_version_error(from, "unknown error");
log_error("Software version result with unrecognised type attribute."); log_error("Software version result with unrecognised type attribute.");
@ -1876,9 +1853,8 @@ _room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
ui_handle_room_configuration_form_error(from, error_message); ui_handle_room_configuration_form_error(from, error_message);
free(error_message);
return 0; return 0;
} }
@ -1932,13 +1908,12 @@ _room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation_set->privilege, from, affiliation_set->item, error_message); log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation_set->privilege, from, affiliation_set->item, error_message);
ProfMucWin* mucwin = wins_get_muc(from); ProfMucWin* mucwin = wins_get_muc(from);
if (mucwin) { if (mucwin) {
mucwin_affiliation_set_error(mucwin, affiliation_set->item, affiliation_set->privilege, error_message); mucwin_affiliation_set_error(mucwin, affiliation_set->item, affiliation_set->privilege, error_message);
} }
free(error_message);
} }
return 0; return 0;
@ -1960,13 +1935,12 @@ _room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userda
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_debug("Error setting role %s list for room %s, user %s: %s", role_set->privilege, from, role_set->item, error_message); log_debug("Error setting role %s list for room %s, user %s: %s", role_set->privilege, from, role_set->item, error_message);
ProfMucWin* mucwin = wins_get_muc(from); ProfMucWin* mucwin = wins_get_muc(from);
if (mucwin) { if (mucwin) {
mucwin_role_set_error(mucwin, role_set->item, role_set->privilege, error_message); mucwin_role_set_error(mucwin, role_set->item, role_set->privilege, error_message);
} }
free(error_message);
} }
return 0; return 0;
@ -1988,13 +1962,12 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* cons
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_debug("Error retrieving %s list for room %s: %s", affiliation_list->affiliation, from, error_message); log_debug("Error retrieving %s list for room %s: %s", affiliation_list->affiliation, from, error_message);
ProfMucWin* mucwin = wins_get_muc(from); ProfMucWin* mucwin = wins_get_muc(from);
if (mucwin && affiliation_list->show_ui_message) { if (mucwin && affiliation_list->show_ui_message) {
mucwin_affiliation_list_error(mucwin, affiliation_list->affiliation, error_message); mucwin_affiliation_list_error(mucwin, affiliation_list->affiliation, error_message);
} }
free(error_message);
return 0; return 0;
} }
GSList* jids = NULL; GSList* jids = NULL;
@ -2045,13 +2018,12 @@ _room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userd
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
log_debug("Error retrieving %s list for room %s: %s", role, from, error_message); log_debug("Error retrieving %s list for room %s: %s", role, from, error_message);
ProfMucWin* mucwin = wins_get_muc(from); ProfMucWin* mucwin = wins_get_muc(from);
if (mucwin) { if (mucwin) {
mucwin_role_list_error(mucwin, role, error_message); mucwin_role_list_error(mucwin, role, error_message);
} }
free(error_message);
return 0; return 0;
} }
GSList* nicks = NULL; GSList* nicks = NULL;
@ -2095,9 +2067,8 @@ _room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
ui_handle_room_config_submit_result_error(from, error_message); ui_handle_room_config_submit_result_error(from, error_message);
free(error_message);
return 0; return 0;
} }
@ -2123,9 +2094,8 @@ _room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
// handle error responses // handle error responses
ProfMucWin* mucwin = wins_get_muc(from); ProfMucWin* mucwin = wins_get_muc(from);
if (mucwin && (g_strcmp0(type, STANZA_TYPE_ERROR) == 0)) { if (mucwin && (g_strcmp0(type, STANZA_TYPE_ERROR) == 0)) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
mucwin_kick_error(mucwin, nick, error_message); mucwin_kick_error(mucwin, nick, error_message);
free(error_message);
} }
return 0; return 0;
@ -2163,9 +2133,8 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
ProfMucWin* mucwin = wins_get_muc(cb_data->room); ProfMucWin* mucwin = wins_get_muc(cb_data->room);
if (mucwin && cb_data->display) { if (mucwin && cb_data->display) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
mucwin_room_info_error(mucwin, error_message); mucwin_room_info_error(mucwin, error_message);
free(error_message);
} }
return 0; return 0;
} }
@ -2256,13 +2225,12 @@ _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const user
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
if (from) { if (from) {
cons_show_error("Last activity request failed for %s: %s", from, error_message); cons_show_error("Last activity request failed for %s: %s", from, error_message);
} else { } else {
cons_show_error("Last activity request failed: %s", error_message); cons_show_error("Last activity request failed: %s", error_message);
} }
free(error_message);
return 0; return 0;
} }
@ -2310,13 +2278,12 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
if (from) { if (from) {
cons_show_error("Service discovery failed for %s: %s", from, error_message); cons_show_error("Service discovery failed for %s: %s", from, error_message);
} else { } else {
cons_show_error("Service discovery failed: %s", error_message); cons_show_error("Service discovery failed: %s", error_message);
} }
free(error_message);
return 0; return 0;
} }
@ -2394,13 +2361,12 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
if (from) { if (from) {
log_error("Service discovery failed for %s: %s", from, error_message); log_error("Service discovery failed for %s: %s", from, error_message);
} else { } else {
log_error("Service discovery failed: %s", error_message); log_error("Service discovery failed: %s", error_message);
} }
free(error_message);
return 0; return 0;
} }
@ -2446,13 +2412,12 @@ _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userda
// handle error responses // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
if (from) { if (from) {
cons_show_error("Uploading '%s' failed for %s: %s", upload->filename, from, error_message); cons_show_error("Uploading '%s' failed for %s: %s", upload->filename, from, error_message);
} else { } else {
cons_show_error("Uploading '%s' failed: %s", upload->filename, error_message); cons_show_error("Uploading '%s' failed: %s", upload->filename, error_message);
} }
free(error_message);
return 0; return 0;
} }
@ -2569,10 +2534,9 @@ iq_send_stanza(xmpp_stanza_t* const stanza)
xmpp_stanza_to_text(stanza, &text, &text_size); xmpp_stanza_to_text(stanza, &text, &text_size);
xmpp_conn_t* conn = connection_get_conn(); xmpp_conn_t* conn = connection_get_conn();
char* plugin_text = plugins_on_iq_stanza_send(text); auto_char char* plugin_text = plugins_on_iq_stanza_send(text);
if (plugin_text) { if (plugin_text) {
xmpp_send_raw_string(conn, "%s", plugin_text); xmpp_send_raw_string(conn, "%s", plugin_text);
free(plugin_text);
} else { } else {
xmpp_send_raw_string(conn, "%s", text); xmpp_send_raw_string(conn, "%s", text);
} }
@ -2745,10 +2709,9 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
{ {
const char* type = xmpp_stanza_get_type(stanza); const char* type = xmpp_stanza_get_type(stanza);
if (g_strcmp0(type, "error") == 0) { if (g_strcmp0(type, "error") == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
cons_show_error("Server error: %s", error_message); cons_show_error("Server error: %s", error_message);
log_debug("MAM Error: %s", error_message); log_debug("MAM Error: %s", error_message);
free(error_message);
} else if (g_strcmp0(type, "result") == 0) { } else if (g_strcmp0(type, "result") == 0) {
xmpp_stanza_t* fin = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_FIN, STANZA_NS_MAM2); xmpp_stanza_t* fin = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_FIN, STANZA_NS_MAM2);
if (fin) { if (fin) {
@ -2782,7 +2745,7 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
if (set) { if (set) {
win_print_loading_history(window); win_print_loading_history(window);
char* firstid = NULL; auto_char char* firstid = NULL;
xmpp_stanza_t* first = xmpp_stanza_get_child_by_name(set, STANZA_NAME_FIRST); xmpp_stanza_t* first = xmpp_stanza_get_child_by_name(set, STANZA_NAME_FIRST);
firstid = xmpp_stanza_get_text(first); firstid = xmpp_stanza_get_text(first);
@ -2794,7 +2757,6 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
data->end_datestr = NULL; data->end_datestr = NULL;
} }
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->start_datestr, NULL, firstid, NULL); xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->start_datestr, NULL, firstid, NULL);
free(firstid);
MamRsmUserdata* ndata = malloc(sizeof(*ndata)); MamRsmUserdata* ndata = malloc(sizeof(*ndata));
*ndata = *data; *ndata = *data;
@ -2833,10 +2795,9 @@ _register_change_password_result_id_handler(xmpp_stanza_t* const stanza, void* c
{ {
const char* type = xmpp_stanza_get_type(stanza); const char* type = xmpp_stanza_get_type(stanza);
if (g_strcmp0(type, "error") == 0) { if (g_strcmp0(type, "error") == 0) {
char* error_message = stanza_get_error_message(stanza); auto_char char* error_message = stanza_get_error_message(stanza);
cons_show_error("Server error: %s", error_message); cons_show_error("Server error: %s", error_message);
log_debug("Password change error: %s", error_message); log_debug("Password change error: %s", error_message);
free(error_message);
} else { } else {
cons_show("Password successfully changed."); cons_show("Password successfully changed.");
log_debug("Password successfully changed."); log_debug("Password successfully changed.");
@ -2884,13 +2845,12 @@ _muc_register_nick_response_handler(xmpp_stanza_t* const stanza, void* const use
void void
iq_submit_muc_register_nick_form(ProfConfWin* confwin) iq_submit_muc_register_nick_form(ProfConfWin* confwin)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
xmpp_stanza_t* iq = stanza_create_muc_register_nick(ctx, id, confwin->roomjid, NULL, confwin->form); xmpp_stanza_t* iq = stanza_create_muc_register_nick(ctx, id, confwin->roomjid, NULL, confwin->form);
iq_id_handler_add(id, _muc_register_nick_response_handler, NULL, NULL); iq_id_handler_add(id, _muc_register_nick_response_handler, NULL, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
@ -2950,7 +2910,7 @@ iq_muc_register_nick(const char* const roomjid)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_to(iq, roomjid); xmpp_stanza_set_to(iq, roomjid);
@ -2961,7 +2921,6 @@ iq_muc_register_nick(const char* const roomjid)
xmpp_stanza_add_child(iq, query); xmpp_stanza_add_child(iq, query);
iq_id_handler_add(id, _muc_register_nick_handler, NULL, NULL); iq_id_handler_add(id, _muc_register_nick_handler, NULL, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);

View File

@ -111,12 +111,8 @@ jid_create(const gchar* const str)
Jid* Jid*
jid_create_from_bare_and_resource(const char* const barejid, const char* const resource) jid_create_from_bare_and_resource(const char* const barejid, const char* const resource)
{ {
Jid* result; auto_char char* jid = create_fulljid(barejid, resource);
char* jid = create_fulljid(barejid, resource); return jid_create(jid);
result = jid_create(jid);
free(jid);
return result;
} }
void void

View File

@ -243,7 +243,7 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
if (carbons) { if (carbons) {
// carbon must come from ourselves // carbon must come from ourselves
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
const char* const stanza_from = xmpp_stanza_get_from(stanza); const char* const stanza_from = xmpp_stanza_get_from(stanza);
if (stanza_from) { if (stanza_from) {
@ -256,8 +256,6 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
msg_stanza = _handle_carbons(carbons); msg_stanza = _handle_carbons(carbons);
} }
} }
free(mybarejid);
} }
if (msg_stanza) { if (msg_stanza) {
@ -425,12 +423,11 @@ message_send_chat(const char* const barejid, const char* const msg, const char*
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
const char* state = chat_session_get_state(barejid); const char* state = chat_session_get_state(barejid);
char* jid = chat_session_get_jid(barejid); auto_char char* jid = chat_session_get_jid(barejid);
char* id = connection_create_stanza_id(); char* id = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg); xmpp_message_set_body(message, msg);
free(jid);
if (state) { if (state) {
stanza_attach_state(ctx, message, state); stanza_attach_state(ctx, message, state);
@ -460,7 +457,7 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
const char* state = chat_session_get_state(barejid); const char* state = chat_session_get_state(barejid);
char* jid = chat_session_get_jid(barejid); auto_char char* jid = chat_session_get_jid(barejid);
char* id = connection_create_stanza_id(); char* id = connection_create_stanza_id();
xmpp_stanza_t* message = NULL; xmpp_stanza_t* message = NULL;
@ -469,7 +466,7 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
ProfAccount* account = accounts_get_account(account_name); ProfAccount* account = accounts_get_account(account_name);
if (account->pgp_keyid) { if (account->pgp_keyid) {
auto_jid Jid* jidp = jid_create(jid); auto_jid Jid* jidp = jid_create(jid);
char* encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid); auto_char char* encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid);
if (encrypted) { if (encrypted) {
message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, "This message is encrypted (XEP-0027)."); xmpp_message_set_body(message, "This message is encrypted (XEP-0027).");
@ -482,7 +479,6 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
xmpp_stanza_release(enc_st); xmpp_stanza_release(enc_st);
xmpp_stanza_add_child(message, x); xmpp_stanza_add_child(message, x);
xmpp_stanza_release(x); xmpp_stanza_release(x);
free(encrypted);
} else { } else {
message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg); xmpp_message_set_body(message, msg);
@ -497,7 +493,6 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg); xmpp_message_set_body(message, msg);
#endif #endif
free(jid);
if (state) { if (state) {
stanza_attach_state(ctx, message, state); stanza_attach_state(ctx, message, state);
@ -586,14 +581,11 @@ message_send_chat_otr(const char* const barejid, const char* const msg, gboolean
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
const char* state = chat_session_get_state(barejid); const char* state = chat_session_get_state(barejid);
char* jid = chat_session_get_jid(barejid);
char* id = connection_create_stanza_id(); char* id = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id); xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id);
xmpp_message_set_body(message, msg); xmpp_message_set_body(message, msg);
free(jid);
if (state) { if (state) {
stanza_attach_state(ctx, message, state); stanza_attach_state(ctx, message, state);
} }
@ -852,7 +844,7 @@ _handle_error(xmpp_stanza_t* const stanza)
} }
// stanza_get_error never returns NULL // stanza_get_error never returns NULL
char* err_msg = stanza_get_error_message(stanza); auto_char char* err_msg = stanza_get_error_message(stanza);
GString* log_msg = g_string_new("message stanza error received"); GString* log_msg = g_string_new("message stanza error received");
if (id) { if (id) {
@ -885,8 +877,6 @@ _handle_error(xmpp_stanza_t* const stanza)
} }
ui_handle_recipient_error(jid, err_msg); ui_handle_recipient_error(jid, err_msg);
} }
free(err_msg);
} }
static void static void
@ -1058,10 +1048,9 @@ _handle_groupchat(xmpp_stanza_t* const stanza)
if (code) { if (code) {
// If configuration change notification send disco info to get updated info of the muc // If configuration change notification send disco info to get updated info of the muc
char* disqo_info_id = connection_create_stanza_id(); auto_char char* disqo_info_id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, disqo_info_id, room_jid, NULL); xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, disqo_info_id, room_jid, NULL);
iq_id_handler_add(disqo_info_id, _room_config_handler, NULL, NULL); iq_id_handler_add(disqo_info_id, _room_config_handler, NULL, NULL);
free(disqo_info_id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
@ -1181,9 +1170,8 @@ _message_send_receipt(const char* const fulljid, const char* const message_id)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, fulljid, id); xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, fulljid, id);
free(id);
xmpp_stanza_t* receipt = xmpp_stanza_new(ctx); xmpp_stanza_t* receipt = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(receipt, "received"); xmpp_stanza_set_name(receipt, "received");
@ -1343,12 +1331,10 @@ _handle_carbons(xmpp_stanza_t* const stanza)
} }
// Eliminate duplicate messages in chat with oneself when another client is sending a message // Eliminate duplicate messages in chat with oneself when another client is sending a message
char* bare_from = xmpp_jid_bare(connection_get_ctx(), xmpp_stanza_get_from(message_stanza)); auto_char char* bare_from = xmpp_jid_bare(connection_get_ctx(), xmpp_stanza_get_from(message_stanza));
if (g_strcmp0(bare_from, xmpp_stanza_get_to(message_stanza)) == 0) { if (g_strcmp0(bare_from, xmpp_stanza_get_to(message_stanza)) == 0) {
free(bare_from);
return NULL; return NULL;
} }
free(bare_from);
return message_stanza; return message_stanza;
} }
@ -1469,7 +1455,7 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
if (message->plain || message->body || message->encrypted) { if (message->plain || message->body || message->encrypted) {
if (is_carbon) { if (is_carbon) {
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
// if we are the recipient, treat as standard incoming message // if we are the recipient, treat as standard incoming message
if (g_strcmp0(mybarejid, message->to_jid->barejid) == 0) { if (g_strcmp0(mybarejid, message->to_jid->barejid) == 0) {
@ -1478,8 +1464,6 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
} else { } else {
sv_ev_outgoing_carbon(message); sv_ev_outgoing_carbon(message);
} }
free(mybarejid);
} else { } else {
sv_ev_incoming_message(message); sv_ev_incoming_message(message);
_receipt_request_handler(stanza); _receipt_request_handler(stanza);
@ -1589,10 +1573,9 @@ _send_message_stanza(xmpp_stanza_t* const stanza)
xmpp_stanza_to_text(stanza, &text, &text_size); xmpp_stanza_to_text(stanza, &text, &text_size);
xmpp_conn_t* conn = connection_get_conn(); xmpp_conn_t* conn = connection_get_conn();
char* plugin_text = plugins_on_message_stanza_send(text); auto_char char* plugin_text = plugins_on_message_stanza_send(text);
if (plugin_text) { if (plugin_text) {
xmpp_send_raw_string(conn, "%s", plugin_text); xmpp_send_raw_string(conn, "%s", plugin_text);
free(plugin_text);
} else { } else {
xmpp_send_raw_string(conn, "%s", text); xmpp_send_raw_string(conn, "%s", text);
} }

View File

@ -885,11 +885,10 @@ muc_members_add(const char* const room, const char* const jid)
if (g_hash_table_insert(chat_room->members, strdup(jid), NULL)) { if (g_hash_table_insert(chat_room->members, strdup(jid), NULL)) {
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
if (chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS) { if (chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
char* our_barejid = connection_get_barejid(); auto_char char* our_barejid = connection_get_barejid();
if (strcmp(jid, our_barejid) != 0) { if (strcmp(jid, our_barejid) != 0) {
omemo_start_session(jid); omemo_start_session(jid);
} }
free(our_barejid);
} }
#endif #endif
} }

View File

@ -86,8 +86,8 @@ void
omemo_devicelist_configure(void) omemo_devicelist_configure(void)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
Jid* jid = jid_create(connection_get_fulljid()); auto_jid Jid* jid = jid_create(connection_get_fulljid());
xmpp_stanza_t* iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, STANZA_NS_OMEMO_DEVICELIST); xmpp_stanza_t* iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, STANZA_NS_OMEMO_DEVICELIST);
@ -96,15 +96,13 @@ omemo_devicelist_configure(void)
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
free(id);
jid_destroy(jid);
} }
void void
omemo_devicelist_request(const char* const jid) omemo_devicelist_request(const char* const jid)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
log_debug("[OMEMO] request device list for jid: %s", jid); log_debug("[OMEMO] request device list for jid: %s", jid);
@ -113,7 +111,6 @@ omemo_devicelist_request(const char* const jid)
iq_send_stanza(iq); iq_send_stanza(iq);
free(id);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }

View File

@ -124,9 +124,8 @@ ox_announce_public_key(const char* const filename)
xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_t* item = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
char* timestamp = _gettimestamp(); auto_char char* timestamp = _gettimestamp();
xmpp_stanza_set_attribute(item, STANZA_ATTR_ID, timestamp); xmpp_stanza_set_attribute(item, STANZA_ATTR_ID, timestamp);
free(timestamp);
xmpp_stanza_t* pubkey = xmpp_stanza_new(ctx); xmpp_stanza_t* pubkey = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubkey, STANZA_NAME_PUPKEY); xmpp_stanza_set_name(pubkey, STANZA_NAME_PUPKEY);
@ -267,9 +266,8 @@ _ox_metadata_node__public_key(const char* const fingerprint)
xmpp_stanza_t* pubkeymetadata = xmpp_stanza_new(ctx); xmpp_stanza_t* pubkeymetadata = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA); xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA);
xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT, fingerprint); xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT, fingerprint);
char* timestamp = _gettimestamp(); auto_char char* timestamp = _gettimestamp();
xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_DATE, timestamp); xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_DATE, timestamp);
free(timestamp);
xmpp_stanza_add_child(publickeyslist, pubkeymetadata); xmpp_stanza_add_child(publickeyslist, pubkeymetadata);
xmpp_stanza_add_child(item, publickeyslist); xmpp_stanza_add_child(item, publickeyslist);
@ -467,7 +465,7 @@ _ox_public_key_result(xmpp_stanza_t* const stanza, void* const userdata)
log_error("[OX] No data"); log_error("[OX] No data");
} }
char* base64_data = xmpp_stanza_get_text(data); auto_char char* base64_data = xmpp_stanza_get_text(data);
if (base64_data) { if (base64_data) {
log_debug("Key data: %s", base64_data); log_debug("Key data: %s", base64_data);
@ -476,8 +474,6 @@ _ox_public_key_result(xmpp_stanza_t* const stanza, void* const userdata)
} else { } else {
cons_show("Public Key import failed. Check log for details."); cons_show("Public Key import failed. Check log for details.");
} }
free(base64_data);
} }
return FALSE; return FALSE;

View File

@ -124,9 +124,8 @@ presence_subscription(const char* const jid, const jabber_subscr_t action)
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
xmpp_stanza_t* presence = xmpp_presence_new(ctx); xmpp_stanza_t* presence = xmpp_presence_new(ctx);
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_set_id(presence, id); xmpp_stanza_set_id(presence, id);
free(id);
xmpp_stanza_set_type(presence, type); xmpp_stanza_set_type(presence, type);
xmpp_stanza_set_to(presence, jidp->barejid); xmpp_stanza_set_to(presence, jidp->barejid);
@ -207,9 +206,8 @@ presence_send(const resource_presence_t presence_type, const int idle, char* sig
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
xmpp_stanza_t* presence = xmpp_presence_new(ctx); xmpp_stanza_t* presence = xmpp_presence_new(ctx);
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_set_id(presence, id); xmpp_stanza_set_id(presence, id);
free(id);
const char* show = stanza_get_presence_string_from_type(presence_type); const char* show = stanza_get_presence_string_from_type(presence_type);
stanza_attach_show(ctx, presence, show); stanza_attach_show(ctx, presence, show);
@ -265,10 +263,9 @@ _send_room_presence(xmpp_stanza_t* presence)
const char* nick = muc_nick(room); const char* nick = muc_nick(room);
if (nick) { if (nick) {
char* full_room_jid = create_fulljid(room, nick); auto_char char* full_room_jid = create_fulljid(room, nick);
xmpp_stanza_set_to(presence, full_room_jid); xmpp_stanza_set_to(presence, full_room_jid);
log_debug("Sending presence to room: %s", full_room_jid); log_debug("Sending presence to room: %s", full_room_jid);
free(full_room_jid);
_send_presence_stanza(presence); _send_presence_stanza(presence);
} }
@ -313,7 +310,7 @@ presence_change_room_nick(const char* const room, const char* const nick)
const char* show = stanza_get_presence_string_from_type(presence_type); const char* show = stanza_get_presence_string_from_type(presence_type);
char* status = connection_get_presence_msg(); char* status = connection_get_presence_msg();
int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type); int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type);
char* full_room_jid = create_fulljid(room, nick); auto_char char* full_room_jid = create_fulljid(room, nick);
xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_ctx_t* ctx = connection_get_ctx();
xmpp_stanza_t* presence = stanza_create_room_newnick_presence(ctx, full_room_jid); xmpp_stanza_t* presence = stanza_create_room_newnick_presence(ctx, full_room_jid);
@ -325,7 +322,6 @@ presence_change_room_nick(const char* const room, const char* const nick)
_send_presence_stanza(presence); _send_presence_stanza(presence);
xmpp_stanza_release(presence); xmpp_stanza_release(presence);
free(full_room_jid);
} }
void void
@ -451,7 +447,7 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
} }
// stanza_get_error never returns NULL // stanza_get_error never returns NULL
char* err_msg = stanza_get_error_message(stanza); auto_char char* err_msg = stanza_get_error_message(stanza);
g_string_append(log_msg, " error="); g_string_append(log_msg, " error=");
g_string_append(log_msg, err_msg); g_string_append(log_msg, err_msg);
@ -464,8 +460,6 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
} else { } else {
ui_handle_error(err_msg); ui_handle_error(err_msg);
} }
free(err_msg);
} }
static void static void
@ -544,7 +538,7 @@ _unavailable_handler(xmpp_stanza_t* const stanza)
} }
if (strcmp(my_jid->barejid, from_jid->barejid) != 0) { if (strcmp(my_jid->barejid, from_jid->barejid) != 0) {
char* status_str = stanza_get_status(stanza, NULL); auto_char char* status_str = stanza_get_status(stanza, NULL);
if (from_jid->resourcepart) { if (from_jid->resourcepart) {
sv_ev_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str); sv_ev_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str);
@ -552,7 +546,6 @@ _unavailable_handler(xmpp_stanza_t* const stanza)
} else { } else {
sv_ev_contact_offline(from_jid->barejid, "__prof_default", status_str); sv_ev_contact_offline(from_jid->barejid, "__prof_default", status_str);
} }
free(status_str);
} else { } else {
if (from_jid->resourcepart) { if (from_jid->resourcepart) {
connection_remove_available_resource(from_jid->resourcepart); connection_remove_available_resource(from_jid->resourcepart);
@ -575,25 +568,22 @@ _handle_caps(const char* const jid, XMPPCaps* caps)
caps_map_jid_to_ver(jid, caps->ver); caps_map_jid_to_ver(jid, caps->ver);
} else { } else {
log_debug("Capabilities cache miss: %s, for %s, sending service discovery request", caps->ver, jid); log_debug("Capabilities cache miss: %s, for %s, sending service discovery request", caps->ver, jid);
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
iq_send_caps_request(jid, id, caps->node, caps->ver); iq_send_caps_request(jid, id, caps->node, caps->ver);
free(id);
} }
} }
// unsupported hash, xep-0115, associate with JID, no cache // unsupported hash, xep-0115, associate with JID, no cache
} else if (caps->hash) { } else if (caps->hash) {
log_info("Hash %s not supported: %s, sending service discovery request", caps->hash, jid); log_info("Hash %s not supported: %s, sending service discovery request", caps->hash, jid);
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
iq_send_caps_request_for_jid(jid, id, caps->node, caps->ver); iq_send_caps_request_for_jid(jid, id, caps->node, caps->ver);
free(id);
// no hash, legacy caps, cache against node#ver // no hash, legacy caps, cache against node#ver
} else if (caps->node && caps->ver) { } else if (caps->node && caps->ver) {
log_info("No hash specified: %s, legacy request made for %s#%s", jid, caps->node, caps->ver); log_info("No hash specified: %s, legacy request made for %s#%s", jid, caps->node, caps->ver);
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
iq_send_caps_request_legacy(jid, id, caps->node, caps->ver); iq_send_caps_request_legacy(jid, id, caps->node, caps->ver);
free(id);
} else { } else {
log_info("No hash specified: %s, could not create ver string, not sending service discovery request.", jid); log_info("No hash specified: %s, could not create ver string, not sending service discovery request.", jid);
} }
@ -783,25 +773,21 @@ _muc_user_self_handler(xmpp_stanza_t* stanza)
// room destroyed // room destroyed
if (stanza_room_destroyed(stanza)) { if (stanza_room_destroyed(stanza)) {
const char* new_jid = stanza_get_muc_destroy_alternative_room(stanza); const char* new_jid = stanza_get_muc_destroy_alternative_room(stanza);
char* password = stanza_get_muc_destroy_alternative_password(stanza); auto_char char* password = stanza_get_muc_destroy_alternative_password(stanza);
char* reason = stanza_get_muc_destroy_reason(stanza); auto_char char* reason = stanza_get_muc_destroy_reason(stanza);
sv_ev_room_destroyed(room, new_jid, password, reason); sv_ev_room_destroyed(room, new_jid, password, reason);
free(password);
free(reason);
// kicked from room // kicked from room
} else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) { } else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) {
const char* actor = stanza_get_actor(stanza); const char* actor = stanza_get_actor(stanza);
char* reason = stanza_get_reason(stanza); auto_char char* reason = stanza_get_reason(stanza);
sv_ev_room_kicked(room, actor, reason); sv_ev_room_kicked(room, actor, reason);
free(reason);
// banned from room // banned from room
} else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) { } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) {
const char* actor = stanza_get_actor(stanza); const char* actor = stanza_get_actor(stanza);
char* reason = stanza_get_reason(stanza); auto_char char* reason = stanza_get_reason(stanza);
sv_ev_room_banned(room, actor, reason); sv_ev_room_banned(room, actor, reason);
free(reason);
// normal exit // normal exit
} else { } else {
@ -818,9 +804,9 @@ _muc_user_self_handler(xmpp_stanza_t* stanza)
} }
muc_nick_change_complete(room, nick); muc_nick_change_complete(room, nick);
char* reason = stanza_get_reason(stanza); auto_char char* reason = stanza_get_reason(stanza);
char* show_str = stanza_get_show(stanza, "online"); auto_char char* show_str = stanza_get_show(stanza, "online");
char* status_str = stanza_get_status(stanza, NULL); auto_char char* status_str = stanza_get_status(stanza, NULL);
const char* actor = stanza_get_actor(stanza); const char* actor = stanza_get_actor(stanza);
const char* jid = NULL; const char* jid = NULL;
const char* role = NULL; const char* role = NULL;
@ -836,9 +822,6 @@ _muc_user_self_handler(xmpp_stanza_t* stanza)
} }
} }
sv_ev_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str); sv_ev_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str);
free(show_str);
free(status_str);
free(reason);
} }
jid_destroy(from_jid); jid_destroy(from_jid);
@ -848,13 +831,13 @@ static void
_muc_user_occupant_handler(xmpp_stanza_t* stanza) _muc_user_occupant_handler(xmpp_stanza_t* stanza)
{ {
const char* from = xmpp_stanza_get_from(stanza); const char* from = xmpp_stanza_get_from(stanza);
Jid* from_jid = jid_create(from); auto_jid Jid* from_jid = jid_create(from);
log_debug("Room presence received from %s", from_jid->fulljid); log_debug("Room presence received from %s", from_jid->fulljid);
char* room = from_jid->barejid; char* room = from_jid->barejid;
char* nick = from_jid->resourcepart; char* nick = from_jid->resourcepart;
char* status_str = stanza_get_status(stanza, NULL); auto_char char* status_str = stanza_get_status(stanza, NULL);
if (!nick) { if (!nick) {
log_warning("presence: jid without resource"); log_warning("presence: jid without resource");
@ -876,16 +859,14 @@ _muc_user_occupant_handler(xmpp_stanza_t* stanza)
// kicked from room // kicked from room
if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) { if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) {
const char* actor = stanza_get_actor(stanza); const char* actor = stanza_get_actor(stanza);
char* reason = stanza_get_reason(stanza); auto_char char* reason = stanza_get_reason(stanza);
sv_ev_room_occupent_kicked(room, nick, actor, reason); sv_ev_room_occupent_kicked(room, nick, actor, reason);
free(reason);
// banned from room // banned from room
} else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) { } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) {
const char* actor = stanza_get_actor(stanza); const char* actor = stanza_get_actor(stanza);
char* reason = stanza_get_reason(stanza); auto_char char* reason = stanza_get_reason(stanza);
sv_ev_room_occupent_banned(room, nick, actor, reason); sv_ev_room_occupent_banned(room, nick, actor, reason);
free(reason);
// normal exit // normal exit
} else { } else {
@ -905,8 +886,8 @@ _muc_user_occupant_handler(xmpp_stanza_t* stanza)
stanza_free_caps(caps); stanza_free_caps(caps);
const char* actor = stanza_get_actor(stanza); const char* actor = stanza_get_actor(stanza);
char* show_str = stanza_get_show(stanza, "online"); auto_char char* show_str = stanza_get_show(stanza, "online");
char* reason = stanza_get_reason(stanza); auto_char char* reason = stanza_get_reason(stanza);
const char* jid = NULL; const char* jid = NULL;
const char* role = NULL; const char* role = NULL;
const char* affiliation = NULL; const char* affiliation = NULL;
@ -920,12 +901,7 @@ _muc_user_occupant_handler(xmpp_stanza_t* stanza)
} }
} }
sv_ev_muc_occupant_online(room, nick, jid, role, affiliation, actor, reason, show_str, status_str); sv_ev_muc_occupant_online(room, nick, jid, role, affiliation, actor, reason, show_str, status_str);
free(show_str);
free(reason);
} }
jid_destroy(from_jid);
free(status_str);
} }
static void static void
@ -968,10 +944,9 @@ _send_presence_stanza(xmpp_stanza_t* const stanza)
xmpp_stanza_to_text(stanza, &text, &text_size); xmpp_stanza_to_text(stanza, &text, &text_size);
xmpp_conn_t* conn = connection_get_conn(); xmpp_conn_t* conn = connection_get_conn();
char* plugin_text = plugins_on_presence_stanza_send(text); auto_char char* plugin_text = plugins_on_presence_stanza_send(text);
if (plugin_text) { if (plugin_text) {
xmpp_send_raw_string(conn, "%s", plugin_text); xmpp_send_raw_string(conn, "%s", plugin_text);
free(plugin_text);
} else { } else {
xmpp_send_raw_string(conn, "%s", text); xmpp_send_raw_string(conn, "%s", text);
} }

View File

@ -84,9 +84,8 @@ void
roster_send_add_new(const char* const barejid, const char* const name) roster_send_add_new(const char* const barejid, const char* const name)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, name, NULL); xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, name, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -104,9 +103,8 @@ void
roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups) roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups)
{ {
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, new_name, groups); xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, new_name, groups);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -123,7 +121,7 @@ roster_send_add_to_group(const char* const group, PContact contact)
new_groups = g_slist_append(new_groups, strdup(group)); new_groups = g_slist_append(new_groups, strdup(group));
// add an id handler to handle the response // add an id handler to handle the response
char* unique_id = connection_create_stanza_id(); auto_char char* unique_id = connection_create_stanza_id();
GroupData* data = malloc(sizeof(GroupData)); GroupData* data = malloc(sizeof(GroupData));
data->group = strdup(group); data->group = strdup(group);
if (p_contact_name(contact)) { if (p_contact_name(contact)) {
@ -138,7 +136,6 @@ roster_send_add_to_group(const char* const group, PContact contact)
p_contact_name(contact), new_groups); p_contact_name(contact), new_groups);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
free(unique_id);
} }
static int static int
@ -166,7 +163,7 @@ roster_send_remove_from_group(const char* const group, PContact contact)
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
// add an id handler to handle the response // add an id handler to handle the response
char* unique_id = connection_create_stanza_id(); auto_char char* unique_id = connection_create_stanza_id();
GroupData* data = malloc(sizeof(GroupData)); GroupData* data = malloc(sizeof(GroupData));
data->group = strdup(group); data->group = strdup(group);
if (p_contact_name(contact)) { if (p_contact_name(contact)) {
@ -180,7 +177,6 @@ roster_send_remove_from_group(const char* const group, PContact contact)
p_contact_name(contact), new_groups); p_contact_name(contact), new_groups);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
free(unique_id);
} }
static int static int
@ -204,17 +200,15 @@ roster_set_handler(xmpp_stanza_t* const stanza)
} }
// if from attribute exists and it is not current users barejid, ignore push // if from attribute exists and it is not current users barejid, ignore push
char* mybarejid = connection_get_barejid(); auto_char char* mybarejid = connection_get_barejid();
const char* from = xmpp_stanza_get_from(stanza); const char* from = xmpp_stanza_get_from(stanza);
if (from && (strcmp(from, mybarejid) != 0)) { if (from && (strcmp(from, mybarejid) != 0)) {
log_warning("Received alleged roster push from: %s", from); log_warning("Received alleged roster push from: %s", from);
free(mybarejid);
return; return;
} }
free(mybarejid);
const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
gchar* barejid_lower = g_utf8_strdown(barejid, -1); auto_gchar gchar* barejid_lower = g_utf8_strdown(barejid, -1);
const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME); const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION); const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
const char* ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK); const char* ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
@ -256,8 +250,6 @@ roster_set_handler(xmpp_stanza_t* const stanza)
} }
} }
g_free(barejid_lower);
return; return;
} }

View File

@ -264,7 +264,7 @@ roster_change_name(PContact contact, const char* const new_name)
assert(roster != NULL); assert(roster != NULL);
assert(contact != NULL); assert(contact != NULL);
char* current_name = NULL; auto_char char* current_name = NULL;
const char* barejid = p_contact_barejid(contact); const char* barejid = p_contact_barejid(contact);
if (p_contact_name(contact)) { if (p_contact_name(contact)) {
@ -273,7 +273,6 @@ roster_change_name(PContact contact, const char* const new_name)
p_contact_set_name(contact, new_name); p_contact_set_name(contact, new_name);
_replace_name(current_name, new_name, barejid); _replace_name(current_name, new_name, barejid);
free(current_name);
} }
void void
@ -415,6 +414,15 @@ roster_add(const char* const barejid, const char* const name, GSList* groups, co
return TRUE; return TRUE;
} }
/**
* Retrieve the bare JID from the roster based on the name.
*
* @param name The name associated with the bare JID.
* @return The corresponding bare JID if found, or NULL if not found.
*
* @note The returned value should not be freed explicitly. The memory
* management is handled by the underlying hash table.
*/
char* char*
roster_barejid_from_name(const char* const name) roster_barejid_from_name(const char* const name)
{ {

View File

@ -121,7 +121,7 @@ session_connect_with_account(const ProfAccount* const account)
saved_account.name = strdup(account->name); saved_account.name = strdup(account->name);
saved_account.passwd = strdup(account->password); saved_account.passwd = strdup(account->password);
char* jid = NULL; auto_char char* jid = NULL;
if (account->resource) { if (account->resource) {
Jid* jidp = jid_create_from_bare_and_resource(account->jid, account->resource); Jid* jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
jid = strdup(jidp->fulljid); jid = strdup(jidp->fulljid);
@ -137,7 +137,6 @@ session_connect_with_account(const ProfAccount* const account)
account->port, account->port,
account->tls_policy, account->tls_policy,
account->auth_policy); account->auth_policy);
free(jid);
return result; return result;
} }
@ -179,9 +178,8 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
Jid* jidp = jid_create(jid); Jid* jidp = jid_create(jid);
if (jidp->resourcepart == NULL) { if (jidp->resourcepart == NULL) {
jid_destroy(jidp); jid_destroy(jidp);
char* resource = jid_random_resource(); auto_char char* resource = jid_random_resource();
jidp = jid_create_from_bare_and_resource(jid, resource); jidp = jid_create_from_bare_and_resource(jid, resource);
free(resource);
saved_details.jid = strdup(jidp->fulljid); saved_details.jid = strdup(jidp->fulljid);
} else { } else {
saved_details.jid = strdup(jid); saved_details.jid = strdup(jid);
@ -560,7 +558,7 @@ session_reconnect_now(void)
return; return;
} }
char* jid = NULL; auto_char char* jid = NULL;
if (account->resource) { if (account->resource) {
jid = create_fulljid(account->jid, account->resource); jid = create_fulljid(account->jid, account->resource);
} else { } else {
@ -578,7 +576,6 @@ session_reconnect_now(void)
log_debug("Attempting reconnect with account %s", account->name); log_debug("Attempting reconnect with account %s", account->name);
connection_connect(jid, saved_account.passwd, server, port, account->tls_policy, account->auth_policy); connection_connect(jid, saved_account.passwd, server, port, account->tls_policy, account->auth_policy);
free(jid);
account_free(account); account_free(account);
if (reconnect_timer) if (reconnect_timer)
g_timer_start(reconnect_timer); g_timer_start(reconnect_timer);

View File

@ -128,9 +128,8 @@ xmpp_stanza_t*
stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid, stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid,
const gboolean autojoin, const char *const nick) const gboolean autojoin, const char *const nick)
{ {
char *id = connection_create_stanza_id(); auto_char char *id = connection_create_stanza_id();
xmpp_stanza_t *stanza = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t *stanza = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
@ -225,7 +224,7 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
xmpp_stanza_set_name(request, STANZA_NAME_REQUEST); xmpp_stanza_set_name(request, STANZA_NAME_REQUEST);
xmpp_stanza_set_ns(request, STANZA_NS_HTTP_UPLOAD); xmpp_stanza_set_ns(request, STANZA_NS_HTTP_UPLOAD);
char* filename_cpy = strdup(upload->filename); auto_char char* filename_cpy = strdup(upload->filename);
// strip spaces from filename (servers don't spaces) // strip spaces from filename (servers don't spaces)
for (int i = 0; i < strlen(filename_cpy); i++) { for (int i = 0; i < strlen(filename_cpy); i++) {
if (filename_cpy[i] == ' ') { if (filename_cpy[i] == ' ') {
@ -233,7 +232,6 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
} }
} }
xmpp_stanza_set_attribute(request, STANZA_ATTR_FILENAME, basename(filename_cpy)); xmpp_stanza_set_attribute(request, STANZA_ATTR_FILENAME, basename(filename_cpy));
free(filename_cpy);
gchar* filesize = g_strdup_printf("%jd", (intmax_t)(upload->filesize)); gchar* filesize = g_strdup_printf("%jd", (intmax_t)(upload->filesize));
if (filesize) { if (filesize) {
@ -252,9 +250,8 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
xmpp_stanza_t* xmpp_stanza_t*
stanza_enable_carbons(xmpp_ctx_t* ctx) stanza_enable_carbons(xmpp_ctx_t* ctx)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* carbons_enable = xmpp_stanza_new(ctx); xmpp_stanza_t* carbons_enable = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE); xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE);
@ -269,9 +266,8 @@ stanza_enable_carbons(xmpp_ctx_t* ctx)
xmpp_stanza_t* xmpp_stanza_t*
stanza_disable_carbons(xmpp_ctx_t* ctx) stanza_disable_carbons(xmpp_ctx_t* ctx)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* carbons_disable = xmpp_stanza_new(ctx); xmpp_stanza_t* carbons_disable = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE); xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE);
@ -286,9 +282,8 @@ stanza_disable_carbons(xmpp_ctx_t* ctx)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_chat_state(xmpp_ctx_t* ctx, const char* const fulljid, const char* const state) stanza_create_chat_state(xmpp_ctx_t* ctx, const char* const fulljid, const char* const state)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id); xmpp_stanza_t* msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
free(id);
xmpp_stanza_t* chat_state = xmpp_stanza_new(ctx); xmpp_stanza_t* chat_state = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(chat_state, state); xmpp_stanza_set_name(chat_state, state);
@ -418,9 +413,8 @@ stanza_attach_x_oob_url(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* cons
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid) stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -483,9 +477,8 @@ xmpp_stanza_t*
stanza_create_invite(xmpp_ctx_t* ctx, const char* const room, stanza_create_invite(xmpp_ctx_t* ctx, const char* const room,
const char* const contact, const char* const reason, const char* const password) const char* const contact, const char* const reason, const char* const password)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, contact, id); xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, contact, id);
free(id);
xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_t* x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_name(x, STANZA_NAME_X);
@ -509,9 +502,8 @@ xmpp_stanza_t*
stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room, stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room,
const char* const contact, const char* const reason) const char* const contact, const char* const reason)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id); xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id);
free(id);
xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_t* x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_name(x, STANZA_NAME_X);
@ -601,9 +593,8 @@ stanza_create_room_leave_presence(xmpp_ctx_t* ctx, const char* const room,
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_jid) stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_jid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room_jid); xmpp_stanza_set_to(iq, room_jid);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -627,9 +618,8 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_ji
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_jid) stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_jid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room_jid); xmpp_stanza_set_to(iq, room_jid);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -651,9 +641,8 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_ji
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid) stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
free(id);
xmpp_stanza_set_to(iq, room_jid); xmpp_stanza_set_to(iq, room_jid);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -669,9 +658,8 @@ stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid) stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room_jid); xmpp_stanza_set_to(iq, room_jid);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -695,9 +683,8 @@ stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const affiliation) stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const affiliation)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -719,9 +706,8 @@ stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room,
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const role) stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const role)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -744,9 +730,8 @@ xmpp_stanza_t*
stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, const char* const jid, stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, const char* const jid,
const char* const affiliation, const char* const reason) const char* const affiliation, const char* const reason)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -782,9 +767,8 @@ xmpp_stanza_t*
stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick, stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick,
const char* const role, const char* const reason) const char* const role, const char* const reason)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -820,9 +804,8 @@ xmpp_stanza_t*
stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick, stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick,
const char* const reason) const char* const reason)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -857,9 +840,8 @@ stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid) stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
free(id);
xmpp_stanza_set_to(iq, fulljid); xmpp_stanza_set_to(iq, fulljid);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -946,9 +928,8 @@ stanza_create_last_activity_iq(xmpp_ctx_t* ctx, const char* const id, const char
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, DataForm* form) stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, DataForm* form)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -1028,9 +1009,8 @@ stanza_contains_chat_state(xmpp_stanza_t* stanza)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target) stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
free(id);
if (target) { if (target) {
xmpp_stanza_set_to(iq, target); xmpp_stanza_set_to(iq, target);
} }
@ -1739,10 +1719,10 @@ stanza_parse_caps(xmpp_stanza_t* const stanza)
EntityCapabilities* EntityCapabilities*
stanza_create_caps_from_query_element(xmpp_stanza_t* query) stanza_create_caps_from_query_element(xmpp_stanza_t* query)
{ {
char* software = NULL; auto_char char* software = NULL;
char* software_version = NULL; auto_char char* software_version = NULL;
char* os = NULL; auto_char char* os = NULL;
char* os_version = NULL; auto_char char* os_version = NULL;
xmpp_stanza_t* softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); xmpp_stanza_t* softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
if (softwareinfo) { if (softwareinfo) {
@ -1851,10 +1831,6 @@ stanza_create_caps_from_query_element(xmpp_stanza_t* query)
EntityCapabilities* result = caps_create(category, type, name, software, software_version, os, os_version, features); EntityCapabilities* result = caps_create(category, type, name, software, software_version, os, os_version, features);
g_slist_free_full(features, free); g_slist_free_full(features, free);
free(software);
free(software_version);
free(os);
free(os_version);
return result; return result;
} }
@ -2209,9 +2185,8 @@ xmpp_stanza_t*
stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target, stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target,
const char* const node) const char* const node)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, target); xmpp_stanza_set_to(iq, target);
xmpp_stanza_t* command = xmpp_stanza_new(ctx); xmpp_stanza_t* command = xmpp_stanza_new(ctx);
@ -2231,9 +2206,8 @@ xmpp_stanza_t*
stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room,
const char* const node, const char* const sessionid, DataForm* form) const char* const node, const char* const sessionid, DataForm* form)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_to(iq, room); xmpp_stanza_set_to(iq, room);
xmpp_stanza_t* command = xmpp_stanza_new(ctx); xmpp_stanza_t* command = xmpp_stanza_new(ctx);
@ -2281,9 +2255,8 @@ stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id,
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid) stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
@ -2306,9 +2279,8 @@ stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids) stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
@ -2541,9 +2513,8 @@ stanza_attach_origin_id(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* cons
static void static void
_stanza_add_unique_id(xmpp_stanza_t* stanza) _stanza_add_unique_id(xmpp_stanza_t* stanza)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_set_id(stanza, id); xmpp_stanza_set_id(stanza, id);
free(id);
} }
static char* static char*
@ -2594,9 +2565,8 @@ stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_i
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_avatar_data_publish_iq(xmpp_ctx_t* ctx, const char* img_data, gsize len) stanza_create_avatar_data_publish_iq(xmpp_ctx_t* ctx, const char* img_data, gsize len)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_FROM, connection_get_fulljid()); xmpp_stanza_set_attribute(iq, STANZA_ATTR_FROM, connection_get_fulljid());
xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
@ -2618,9 +2588,8 @@ stanza_create_avatar_data_publish_iq(xmpp_ctx_t* ctx, const char* img_data, gsiz
xmpp_stanza_set_ns(data, STANZA_NS_USER_AVATAR_DATA); xmpp_stanza_set_ns(data, STANZA_NS_USER_AVATAR_DATA);
xmpp_stanza_t* text = xmpp_stanza_new(ctx); xmpp_stanza_t* text = xmpp_stanza_new(ctx);
gchar* base64 = g_base64_encode((guchar*)img_data, len); auto_gchar gchar* base64 = g_base64_encode((guchar*)img_data, len);
xmpp_stanza_set_text(text, base64); xmpp_stanza_set_text(text, base64);
free(base64);
xmpp_stanza_add_child(data, text); xmpp_stanza_add_child(data, text);
xmpp_stanza_add_child(item, data); xmpp_stanza_add_child(item, data);
@ -2640,9 +2609,8 @@ stanza_create_avatar_data_publish_iq(xmpp_ctx_t* ctx, const char* img_data, gsiz
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_avatar_metadata_publish_iq(xmpp_ctx_t* ctx, const char* img_data, gsize len, int height, int width) stanza_create_avatar_metadata_publish_iq(xmpp_ctx_t* ctx, const char* img_data, gsize len, int height, int width)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_FROM, connection_get_fulljid()); xmpp_stanza_set_attribute(iq, STANZA_ATTR_FROM, connection_get_fulljid());
xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
@ -2692,9 +2660,8 @@ stanza_create_avatar_metadata_publish_iq(xmpp_ctx_t* ctx, const char* img_data,
xmpp_stanza_t* xmpp_stanza_t*
stanza_disable_avatar_publish_iq(xmpp_ctx_t* ctx) stanza_disable_avatar_publish_iq(xmpp_ctx_t* ctx)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_FROM, connection_get_fulljid()); xmpp_stanza_set_attribute(iq, STANZA_ATTR_FROM, connection_get_fulljid());
xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
@ -2773,9 +2740,8 @@ _text_stanza(xmpp_ctx_t* ctx, const char* name, const char* text)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate, const char* const enddate, const char* const firstid, const char* const lastid) stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate, const char* const enddate, const char* const firstid, const char* const lastid)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
// xmpp_stanza_set_to(iq, jid); // xmpp_stanza_set_to(iq, jid);
xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_t* query = xmpp_stanza_new(ctx);
@ -2861,9 +2827,8 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
xmpp_stanza_t* xmpp_stanza_t*
stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* const password) stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* const password)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* change_password = xmpp_stanza_new(ctx); xmpp_stanza_t* change_password = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(change_password, STANZA_NAME_QUERY); xmpp_stanza_set_name(change_password, STANZA_NAME_QUERY);
@ -2898,9 +2863,8 @@ stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* cons
xmpp_stanza_t* xmpp_stanza_t*
stanza_register_new_account(xmpp_ctx_t* ctx, const char* const user, const char* const password) stanza_register_new_account(xmpp_ctx_t* ctx, const char* const user, const char* const password)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* register_new_account = xmpp_stanza_new(ctx); xmpp_stanza_t* register_new_account = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(register_new_account, STANZA_NAME_QUERY); xmpp_stanza_set_name(register_new_account, STANZA_NAME_QUERY);
@ -2935,9 +2899,8 @@ stanza_register_new_account(xmpp_ctx_t* ctx, const char* const user, const char*
xmpp_stanza_t* xmpp_stanza_t*
stanza_request_voice(xmpp_ctx_t* ctx, const char* const room) stanza_request_voice(xmpp_ctx_t* ctx, const char* const room)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id); xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id);
free(id);
xmpp_stanza_t* request_voice_st = xmpp_stanza_new(ctx); xmpp_stanza_t* request_voice_st = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(request_voice_st, STANZA_NAME_X); xmpp_stanza_set_name(request_voice_st, STANZA_NAME_X);
@ -2993,9 +2956,8 @@ stanza_request_voice(xmpp_ctx_t* ctx, const char* const room)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_approve_voice(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form) stanza_create_approve_voice(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form)
{ {
char* stid = connection_create_stanza_id(); auto_char char* stid = connection_create_stanza_id();
xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, jid, stid); xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, jid, stid);
free(stid);
xmpp_stanza_t* x = form_create_submission(form); xmpp_stanza_t* x = form_create_submission(form);

View File

@ -1242,12 +1242,11 @@ vcard_print(xmpp_ctx_t* ctx, ProfWin* window, char* jid)
data->window = window; data->window = window;
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_vcard_request_iq(ctx, jid, id); xmpp_stanza_t* iq = stanza_create_vcard_request_iq(ctx, jid, id);
iq_id_handler_add(id, _vcard_print_result, (ProfIqFreeCallback)_free_userdata, data); iq_id_handler_add(id, _vcard_print_result, (ProfIqFreeCallback)_free_userdata, data);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -1306,9 +1305,8 @@ _vcard_photo_result(xmpp_stanza_t* const stanza, void* userdata)
GString* filename; GString* filename;
if (!data->filename) { if (!data->filename) {
char* path = files_get_data_path(DIR_PHOTOS); auto_gchar gchar* path = files_get_data_path(DIR_PHOTOS);
filename = g_string_new(path); filename = g_string_new(path);
free(path);
g_string_append(filename, "/"); g_string_append(filename, "/");
errno = 0; errno = 0;
@ -1405,12 +1403,11 @@ vcard_photo(xmpp_ctx_t* ctx, char* jid, char* filename, int index, gboolean open
data->filename = strdup(filename); data->filename = strdup(filename);
} }
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_vcard_request_iq(ctx, jid, id); xmpp_stanza_t* iq = stanza_create_vcard_request_iq(ctx, jid, id);
iq_id_handler_add(id, _vcard_photo_result, (ProfIqFreeCallback)_free_userdata, data); iq_id_handler_add(id, _vcard_photo_result, (ProfIqFreeCallback)_free_userdata, data);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -1441,12 +1438,11 @@ vcard_user_refresh(void)
return; return;
} }
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = stanza_create_vcard_request_iq(connection_get_ctx(), NULL, id); xmpp_stanza_t* iq = stanza_create_vcard_request_iq(connection_get_ctx(), NULL, id);
iq_id_handler_add(id, _vcard_refresh_result, NULL, NULL); iq_id_handler_add(id, _vcard_refresh_result, NULL, NULL);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
@ -1455,7 +1451,7 @@ vcard_user_refresh(void)
void void
vcard_upload(xmpp_ctx_t* ctx, vCard* vcard) vcard_upload(xmpp_ctx_t* ctx, vCard* vcard)
{ {
char* id = connection_create_stanza_id(); auto_char char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_from(iq, connection_get_fulljid()); xmpp_stanza_set_from(iq, connection_get_fulljid());
@ -1463,14 +1459,12 @@ vcard_upload(xmpp_ctx_t* ctx, vCard* vcard)
if (!vcard_stanza) { if (!vcard_stanza) {
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
free(id);
return; return;
} }
xmpp_stanza_add_child(iq, vcard_stanza); xmpp_stanza_add_child(iq, vcard_stanza);
xmpp_stanza_release(vcard_stanza); xmpp_stanza_release(vcard_stanza);
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }

View File

@ -73,7 +73,7 @@ cmd_alias_add_adds_alias(void** state)
gboolean result = cmd_alias(NULL, CMD_ALIAS, args); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
char* returned_val = prefs_get_alias("hc"); gchar* returned_val = prefs_get_alias("hc");
assert_string_equal("/help commands", returned_val); assert_string_equal("/help commands", returned_val);
free(returned_val); free(returned_val);
@ -106,7 +106,7 @@ cmd_alias_remove_removes_alias(void** state)
gboolean result = cmd_alias(NULL, CMD_ALIAS, args); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
char* returned_val = prefs_get_alias("hn"); gchar* returned_val = prefs_get_alias("hn");
assert_null(returned_val); assert_null(returned_val);
free(returned_val); free(returned_val);