Commit 3f7ec0eb authored by DanmeiChen's avatar DanmeiChen
Browse files

fix crash with magic research

parent d2155cd7
...@@ -173,6 +173,12 @@ list<SearchResult> MagicSearch::getContactListFromFilter (const string &filter, ...@@ -173,6 +173,12 @@ list<SearchResult> MagicSearch::getContactListFromFilter (const string &filter,
return returnList; return returnList;
} }
static int compareStringItems(const char *a, const char *b) {
if (a == nullptr) a = "";
if (b == nullptr) b = "";
return strcmp(a, b);
}
///////////////////// /////////////////////
// Private Methods // // Private Methods //
///////////////////// /////////////////////
...@@ -298,7 +304,7 @@ list<SearchResult> *MagicSearch::beginNewSearch (const string &filter, const str ...@@ -298,7 +304,7 @@ list<SearchResult> *MagicSearch::beginNewSearch (const string &filter, const str
// Check in order: Friend's display name, address username, address domain, phone number // Check in order: Friend's display name, address username, address domain, phone number
if (name1 == name2) { if (name1 == name2) {
if (lsr.getAddress() && rsr.getAddress()) { if (lsr.getAddress() && rsr.getAddress()) {
int usernameComp = strcmp(linphone_address_get_username(lsr.getAddress()), linphone_address_get_username(rsr.getAddress())); int usernameComp = compareStringItems(linphone_address_get_username(lsr.getAddress()), linphone_address_get_username(rsr.getAddress()));
if (usernameComp == 0) { if (usernameComp == 0) {
int domainComp = strcmp(linphone_address_get_domain(lsr.getAddress()), linphone_address_get_domain(rsr.getAddress())); int domainComp = strcmp(linphone_address_get_domain(lsr.getAddress()), linphone_address_get_domain(rsr.getAddress()));
if (domainComp == 0) { if (domainComp == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment