diff options
| author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-06-06 20:36:28 +0000 | 
|---|---|---|
| committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-06-06 20:36:28 +0000 | 
| commit | fcb09f4016ced43843625b197d851c90088dd418 (patch) | |
| tree | 477c6f11bbba6396196cae410860634a48e22171 | |
| parent | f1a8e719f5687bb32f2f5ed59f26a3203ad43efb (diff) | |
sdptool: fixed memory leak for setattr and setseq
| -rw-r--r-- | tools/sdptool.c | 23 | 
1 files changed, 14 insertions, 9 deletions
| diff --git a/tools/sdptool.c b/tools/sdptool.c index 8864dc99..1bf3526c 100644 --- a/tools/sdptool.c +++ b/tools/sdptool.c @@ -755,10 +755,12 @@ static int set_attrib(sdp_session_t *sess, uint32_t handle, uint16_t attrib, cha  	sdp_list_t *attrid_list;  	uint32_t range = 0x0000ffff;  	sdp_record_t *rec; +	int ret;  	/* Get the old SDP record */  	attrid_list = sdp_list_append(NULL, &range);  	rec = sdp_service_attr_req(sess, handle, SDP_ATTR_REQ_RANGE, attrid_list); +	sdp_list_free(attrid_list, NULL);  	if (!rec) {  		printf("Service get request failed.\n"); @@ -794,11 +796,11 @@ static int set_attrib(sdp_session_t *sess, uint32_t handle, uint16_t attrib, cha  	}  	/* Update on the server */ -	if (sdp_device_record_update(sess, &interface, rec)) { +	ret = sdp_device_record_update(sess, &interface, rec); +	if (ret < 0)  		printf("Service Record update failed (%d).\n", errno); -		return -1; -	} -	return 0; +	sdp_record_free(rec); +	return ret;  }  static struct option set_options[] = { @@ -867,11 +869,12 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri  	uint8_t uuid16 = SDP_UUID16;  	uint8_t uint32 = SDP_UINT32;  	uint8_t str8 = SDP_TEXT_STR8; -	int i; +	int i, ret = 0;  	/* Get the old SDP record */  	attrid_list = sdp_list_append(NULL, &range);  	rec = sdp_service_attr_req(session, handle, SDP_ATTR_REQ_RANGE, attrid_list); +	sdp_list_free(attrid_list, NULL);  	if (!rec) {  		printf("Service get request failed.\n"); @@ -919,10 +922,9 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri  		sdp_attr_replace(rec, attrib, pSequenceHolder);  		/* Update on the server */ -		if (sdp_device_record_update(session, &interface, rec)) { +		ret = sdp_device_record_update(session, &interface, rec); +		if (ret < 0)  			printf("Service Record update failed (%d).\n", errno); -			return -1; -		}  	} else  		printf("Failed to create pSequenceHolder\n"); @@ -932,8 +934,11 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri  	free(dtdArray);  	free(valueArray); +	free(allocArray); -	return 0; +	sdp_record_free(rec); + +	return ret;  }  static struct option seq_options[] = { | 
