diff options
| author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-06-12 18:56:35 +0000 | 
|---|---|---|
| committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-06-12 18:56:35 +0000 | 
| commit | 12d3525ecefcc8ec1962572457cf49834a078b9a (patch) | |
| tree | 0233efe23ba6b341296647b656e0a9a1fe40893a | |
| parent | c6136c57053db24e9c4e2448f25bd46f6a90b053 (diff) | |
UpdateServiceRecord: removed mem leak(when sdpd is running)
| -rw-r--r-- | hcid/dbus-database.c | 26 | 
1 files changed, 12 insertions, 14 deletions
| diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index e4d8e4b3..0a6139a3 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -227,7 +227,6 @@ static DBusHandlerResult update_service_record(DBusConnection *conn,  						DBusMessage *msg, void *data)  {  	struct record_data *user_record; -	DBusMessage *reply;  	DBusMessageIter iter, array;  	sdp_record_t *sdp_record;  	dbus_uint32_t handle; @@ -247,20 +246,14 @@ static DBusHandlerResult update_service_record(DBusConnection *conn,  	if (!user_record)  		return error_not_available(conn, msg); -	reply = dbus_message_new_method_return(msg); -	if (!reply) -		return DBUS_HANDLER_RESULT_NEED_MEMORY; -  	sdp_record = sdp_extract_pdu(bin_record, &scanned);  	if (!sdp_record) {  		error("Parsing of service record failed"); -		dbus_message_unref(reply);  		return error_invalid_arguments(conn, msg);  	}  	if (scanned != size) {  		error("Size mismatch of service record"); -		dbus_message_unref(reply);  		sdp_record_free(sdp_record);  		return error_invalid_arguments(conn, msg);  	} @@ -271,17 +264,22 @@ static DBusHandlerResult update_service_record(DBusConnection *conn,  		sdp_record->handle = handle;  		err = add_record_to_server(sdp_record); -	} else +		if (err < 0) { +			sdp_record_free(sdp_record); +			error("Failed to update the service record"); +			return error_failed(conn, msg, EIO); +		} +	} else {  		err = update_sdp_record(handle, sdp_record); - -	if (err < 0) { -		error("Failed to update the service record"); -		dbus_message_unref(reply);  		sdp_record_free(sdp_record); -		return error_failed(conn, msg, EIO); +		if (err < 0) { +			error("Failed to update the service record"); +			return error_failed(conn, msg, EIO); +		}  	} -	return send_message_and_unref(conn, reply); +	return send_message_and_unref(conn, +			dbus_message_new_method_return(msg));  }  static DBusHandlerResult remove_service_record(DBusConnection *conn, | 
