diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c
index 06ae1ec..4a14eca 100644
--- a/obexd/plugins/phonebook-ebook.c
+++ b/obexd/plugins/phonebook-ebook.c
DBG("collected %d vcards", count);
data->queued_calls--;
- if (data->queued_calls == 0)
- data->contacts_cb(data->buf->str, data->buf->len, data->count,
+ if (data->queued_calls == 0) {
+ GString *buf = data->buf;
+ data->buf = NULL;
+
+ data->contacts_cb(buf->str, buf->len, data->count,
0, TRUE, data->user_data);
+
+ g_string_free(buf, TRUE);
+ }
}
static void ebook_entry_cb(EBook *book, const GError *gerr,