prevent segfault
In case we're not connected yet and press Alt+c a segfault occurred since `conn.xmpp_conn` is dereferenced while it's still `NULL`. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
@@ -51,6 +51,9 @@ get_message_from_editor(gchar* message, gchar** returned_message)
|
|||||||
{
|
{
|
||||||
// create editor dir if not present
|
// create editor dir if not present
|
||||||
char* jid = connection_get_barejid();
|
char* jid = connection_get_barejid();
|
||||||
|
if (!jid) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
gchar* path = files_get_account_data_path(DIR_EDITOR, jid);
|
gchar* path = files_get_account_data_path(DIR_EDITOR, jid);
|
||||||
free(jid);
|
free(jid);
|
||||||
if (g_mkdir_with_parents(path, S_IRWXU) != 0) {
|
if (g_mkdir_with_parents(path, S_IRWXU) != 0) {
|
||||||
|
|||||||
@@ -747,6 +747,8 @@ connection_get_ctx(void)
|
|||||||
const char*
|
const char*
|
||||||
connection_get_fulljid(void)
|
connection_get_fulljid(void)
|
||||||
{
|
{
|
||||||
|
if (!conn.xmpp_conn)
|
||||||
|
return NULL;
|
||||||
const char* jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
|
const char* jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
|
||||||
if (jid) {
|
if (jid) {
|
||||||
return jid;
|
return jid;
|
||||||
@@ -759,10 +761,11 @@ char*
|
|||||||
connection_get_barejid(void)
|
connection_get_barejid(void)
|
||||||
{
|
{
|
||||||
const char* jid = connection_get_fulljid();
|
const char* jid = connection_get_fulljid();
|
||||||
char* result;
|
if (!jid)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
Jid* jidp = jid_create(jid);
|
Jid* jidp = jid_create(jid);
|
||||||
result = strdup(jidp->barejid);
|
char* result = strdup(jidp->barejid);
|
||||||
jid_destroy(jidp);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -772,8 +775,9 @@ char*
|
|||||||
connection_get_user(void)
|
connection_get_user(void)
|
||||||
{
|
{
|
||||||
const char* jid = connection_get_fulljid();
|
const char* jid = connection_get_fulljid();
|
||||||
char* result;
|
if (!jid)
|
||||||
result = strdup(jid);
|
return NULL;
|
||||||
|
char* result = strdup(jid);
|
||||||
|
|
||||||
char* split = strchr(result, '@');
|
char* split = strchr(result, '@');
|
||||||
*split = '\0';
|
*split = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user