From 9a4318f6d23707a7411f4e3b80b05e3c55b3d428 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 3 Oct 2012 12:04:02 +0300 Subject: [PATCH] core: Fix freeing external profile record The add_record_to_server function takes ownership of the service record so it only needs to be freed if the function fails. --- src/profile.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/profile.c b/src/profile.c index 4c8f3c677..f953b8458 100644 --- a/src/profile.c +++ b/src/profile.c @@ -444,7 +444,6 @@ static sdp_record_t *ext_get_record(struct ext_profile *ext) static uint16_t ext_register_record(struct ext_profile *ext, bdaddr_t *src) { sdp_record_t *rec; - uint16_t handle; if (ext->record) rec = sdp_xml_parse_record(ext->record, strlen(ext->record)); @@ -456,14 +455,11 @@ static uint16_t ext_register_record(struct ext_profile *ext, bdaddr_t *src) if (add_record_to_server(src, rec) < 0) { error("Failed to register service record"); + sdp_record_free(rec); return 0; } - handle = rec->handle; - - sdp_record_free(rec); - - return handle; + return rec->handle; } static int ext_start_servers(struct ext_profile *ext, -- 2.47.3