diff --git a/src/device.c b/src/device.c
index c659164..0339bcf 100644
--- a/src/device.c
+++ b/src/device.c
char srcaddr[18], dstaddr[18];
bdaddr_t src;
sdp_list_t *records;
- GSList *l;
+ GSList *l, *next;
adapter_get_address(adapter, &src);
ba2str(&src, srcaddr);
if (records)
sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
- for (l = device->profiles; l != NULL; l = g_slist_next(l)) {
+ for (l = device->profiles; l != NULL; l = next) {
struct btd_profile *profile = l->data;
GSList *probe_uuids;
+ next = l->next;
probe_uuids = device_match_profile(device, profile,
device->uuids);
if (probe_uuids != NULL) {