diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
index 13742da..11cb678 100644
--- a/obexd/plugins/pbap.c
+++ b/obexd/plugins/pbap.c
goto done;
}
- if (pbap->cache.entries == NULL) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap, G_IO_ERR, -ENOENT);
- return;
- }
-
/*
* Don't free the sorted list content: this list contains
* only the reference for the "real" cache entry.
pbap->params->searchattrib,
(const char *) pbap->params->searchval);
+ if (sorted == NULL) {
+ pbap->cache.valid = TRUE;
+ obex_object_set_io_flags(pbap, G_IO_ERR, -ENOENT);
+ return;
+ }
+
/* Computing offset considering first entry of the phonebook */
l = g_slist_nth(sorted, pbap->params->liststartoffset);