Diff between f0e2e1d7b1c3928d5f03f90e3035f92bc5c29ad6 and f809a5e6a7664f57fe678b1fad0d45e76f447e87

Changed Files

File Additions Deletions Status
obexd/plugins/pbap.c +6 -6 modified

Full Patch

diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
index f7b168d..96b6452 100644
--- a/obexd/plugins/pbap.c
+++ b/obexd/plugins/pbap.c
@@ -389,21 +389,21 @@ static void cache_ready_notify(void *user_data)
 		pbap->buffer = g_string_new_len(aparam, sizeof(aparam));
 		goto done;
 	}
-
-	/* Computing off set considering first entry of the phonebook */
-	l = g_slist_nth(pbap->cache.entries, pbap->params->liststartoffset);
-
 	/*
 	 * Don't free the sorted list content: this list contains
 	 * only the reference for the "real" cache entry.
 	 */
-	sorted = sort_entries(l, pbap->params->order,
+	sorted = sort_entries(pbap->cache.entries, pbap->params->order,
 			pbap->params->searchattrib,
 			(const char *) pbap->params->searchval);
 
+	/* Computing offset considering first entry of the phonebook */
+	l = g_slist_nth(sorted, pbap->params->liststartoffset);
+
 	pbap->buffer = g_string_new(VCARD_LISTING_BEGIN);
-	for (l = sorted; l && max; l = l->next, max--) {
+	for (; l && max; l = l->next, max--) {
 		const struct cache_entry *entry = l->data;
+
 		g_string_append_printf(pbap->buffer, VCARD_LISTING_ELEMENT,
 						entry->handle, entry->name);
 	}