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

Fixed possible segfault when no type attribute on incoming messages

This commit is contained in:
James Booth 2012-10-22 10:05:38 +01:00
parent 3f8813bb1b
commit a314e03db2

View File

@ -255,12 +255,13 @@ static int
_message_handler(xmpp_conn_t * const conn, _message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
{ {
char *type; char *type = NULL;
char *from; char *from = NULL;
type = xmpp_stanza_get_attribute(stanza, "type"); type = xmpp_stanza_get_attribute(stanza, "type");
from = xmpp_stanza_get_attribute(stanza, "from"); from = xmpp_stanza_get_attribute(stanza, "from");
if (type != NULL) {
if (strcmp(type, "error") == 0) { if (strcmp(type, "error") == 0) {
char *err_msg = NULL; char *err_msg = NULL;
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, "error"); xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, "error");
@ -280,6 +281,7 @@ _message_handler(xmpp_conn_t * const conn,
prof_handle_error_message(from, err_msg); prof_handle_error_message(from, err_msg);
return 1; return 1;
} }
}
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body"); xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");