diff --git a/src/calls-contacts-provider.c b/src/calls-contacts-provider.c index 5652359..4640a60 100644 --- a/src/calls-contacts-provider.c +++ b/src/calls-contacts-provider.c @@ -422,9 +422,9 @@ calls_contacts_provider_lookup_id (CallsContactsProvider *self, g_return_val_if_fail (CALLS_IS_CONTACTS_PROVIDER (self), NULL); if (STR_IS_NULL_OR_EMPTY (id)) - return NULL; - - best_match = g_hash_table_lookup (self->best_matches, id); + best_match = g_hash_table_lookup (self->best_matches, ""); + else + best_match = g_hash_table_lookup (self->best_matches, id); if (best_match) return g_object_ref (best_match); @@ -435,7 +435,7 @@ calls_contacts_provider_lookup_id (CallsContactsProvider *self, best_match, "country-code", G_BINDING_SYNC_CREATE); - g_hash_table_insert (self->best_matches, g_strdup (id), best_match); + g_hash_table_insert (self->best_matches, g_strdup (id ?: ""), best_match); return g_object_ref (best_match); } diff --git a/tests/test-contacts.c b/tests/test-contacts.c index b974d2c..c970b34 100644 --- a/tests/test-contacts.c +++ b/tests/test-contacts.c @@ -16,10 +16,10 @@ test_contacts_null_contact (void) { g_autoptr (CallsContactsProvider) contacts_provider = calls_contacts_provider_new (); - CallsBestMatch *best_match; + g_autoptr (CallsBestMatch) best_match = NULL; best_match = calls_contacts_provider_lookup_id (contacts_provider, NULL); - g_assert_null (best_match); + g_assert_nonnull (best_match); g_assert_cmpstr (calls_best_match_get_primary_info (best_match), ==, "Anonymous caller"); g_assert_cmpstr (calls_best_match_get_secondary_info (best_match), ==, "");