summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-10 21:42:28 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-10 21:42:28 +0300
commit1d3637c7e9812fcc40aea20f1855edcfe62b5d09 (patch)
tree43e94ad234e0690b68234c51cc856e84eb258a86 /src/mir_app
parent777b9bc02bec68f5075cf6cc7a17b2c1ef2bde91 (diff)
crash fixed when account name equals protocol name
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/proto_chains.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp
index 83391ccc0d..bb8b91cb31 100644
--- a/src/mir_app/src/proto_chains.cpp
+++ b/src/mir_app/src/proto_chains.cpp
@@ -171,23 +171,22 @@ MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char *szProto)
MIR_APP_DLL(int) Proto_AddToContact(MCONTACT hContact, const char *szProto)
{
- PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(szProto);
- if (pd == nullptr) {
- PROTOACCOUNT *pa = Proto_GetAccount(szProto);
- if (pa) {
- db_set_s(hContact, "Protocol", "p", szProto);
+ if (auto *pa = Proto_GetAccount(szProto)) {
+ db_set_s(hContact, "Protocol", "p", szProto);
- if (pa->ppro)
- pa->ppro->OnContactAdded(hContact);
- return 0;
- }
- return 1;
+ if (pa->ppro)
+ pa->ppro->OnContactAdded(hContact);
+ return 0;
}
- if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL || pd->type == PROTOTYPE_PROTOWITHACCS)
- db_set_s(hContact, "Protocol", "p", szProto);
+ if (auto *pd = Proto_IsProtocolLoaded(szProto)) {
+ if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL || pd->type == PROTOTYPE_PROTOWITHACCS)
+ db_set_s(hContact, "Protocol", "p", szProto);
- return 0;
+ return 0;
+ }
+
+ return 1;
}
MIR_APP_DLL(int) Proto_RemoveFromContact(MCONTACT hContact, const char *szProto)