summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_groupchat.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-19 01:13:01 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-19 19:24:16 +0300
commitc9e483e0fb1566d210530339d13a0e6e91260200 (patch)
tree92e35cfeef803235fdad89b69968d4b6fd64abdf /protocols/JabberG/src/jabber_groupchat.cpp
parentaf9bb538a0609893db7d5f2582595660395f0821 (diff)
more checks for GetText()
Diffstat (limited to 'protocols/JabberG/src/jabber_groupchat.cpp')
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index dda33f7879..d4c595d391 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -841,19 +841,21 @@ void CJabberProto::GroupchatProcessPresence(const TiXmlElement *node)
// Update status of room participant
int status = ID_STATUS_ONLINE;
- const char *ptszShow = node->FirstChildElement("show")->GetText();
- if (ptszShow) {
- if (!mir_strcmp(ptszShow, "away")) status = ID_STATUS_AWAY;
- else if (!mir_strcmp(ptszShow, "xa")) status = ID_STATUS_NA;
- else if (!mir_strcmp(ptszShow, "dnd")) status = ID_STATUS_DND;
- else if (!mir_strcmp(ptszShow, "chat")) status = ID_STATUS_FREECHAT;
+ if (auto *n = node->FirstChildElement("show")) {
+ if (!mir_strcmp(n->GetText(), "away")) status = ID_STATUS_AWAY;
+ else if (!mir_strcmp(n->GetText(), "xa")) status = ID_STATUS_NA;
+ else if (!mir_strcmp(n->GetText(), "dnd")) status = ID_STATUS_DND;
+ else if (!mir_strcmp(n->GetText(), "chat")) status = ID_STATUS_FREECHAT;
}
- const char *str = node->FirstChildElement("status")->GetText();
+ const char *str = nullptr;
+ if (auto *n = node->FirstChildElement("status"))
+ str = n->GetText();
char priority = 0;
- if (auto *ptszPriority = node->FirstChildElement("priority")->GetText())
- priority = atoi(ptszPriority);
+ if (auto *n = node->FirstChildElement("priority"))
+ if (n->GetText())
+ priority = atoi(n->GetText());
bool bStatusChanged = false, bRoomCreated = false, bAffiliationChanged = false, bRoleChanged = false;
int newRes = ListAddResource(LIST_CHATROOM, from, status, str, priority, cnick) ? GC_EVENT_JOIN : 0;