mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-29 07:24:55 +00:00 
			
		
		
		
	Cleanup reference leaks in res_jabber
res_jabber.c had a number of places where astobjs would be referenced and have their reference counts bumped without having a dereference made before the object lost scope. This patch adds a number of ASTOBJ_UNREFs to resolve that. Review: https://reviewboard.asterisk.org/r/1478/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342545 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -2072,6 +2072,7 @@ static int aji_dinfo_handler(void *data, ikspak *pak) | ||||
| 	resource = aji_find_resource(buddy, pak->from->resource); | ||||
| 	if (pak->subtype == IKS_TYPE_ERROR) { | ||||
| 		ast_log(LOG_WARNING, "Received error from a client, turn on jabber debug!\n"); | ||||
| 		ASTOBJ_UNREF(client, aji_client_destroy); | ||||
| 		return IKS_FILTER_EAT; | ||||
| 	} | ||||
| 	if (pak->subtype == IKS_TYPE_RESULT) { | ||||
| @@ -2975,6 +2976,7 @@ static int aji_filter_roster(void *data, ikspak *pak) | ||||
| 			buddy = ast_calloc(1, sizeof(*buddy)); | ||||
| 			if (!buddy) { | ||||
| 				ast_log(LOG_WARNING, "Out of memory\n"); | ||||
| 				ASTOBJ_UNREF(client, aji_client_destroy); | ||||
| 				return 0; | ||||
| 			} | ||||
| 			ASTOBJ_INIT(buddy); | ||||
| @@ -3172,6 +3174,7 @@ static void aji_mwi_cb(const struct ast_event *ast_event, void *data) | ||||
| 	snprintf(newmsgs, sizeof(newmsgs), "%d", | ||||
| 		ast_event_get_ie_uint(ast_event, AST_EVENT_IE_NEWMSGS)); | ||||
| 	aji_publish_mwi(client, mailbox, context, oldmsgs, newmsgs); | ||||
| 	ASTOBJ_UNREF(client, aji_client_destroy); | ||||
|  | ||||
| } | ||||
| /*! | ||||
| @@ -3196,6 +3199,7 @@ static void aji_devstate_cb(const struct ast_event *ast_event, void *data) | ||||
| 	device = ast_event_get_ie_str(ast_event, AST_EVENT_IE_DEVICE); | ||||
| 	device_state = ast_devstate_str(ast_event_get_ie_uint(ast_event, AST_EVENT_IE_STATE)); | ||||
| 	aji_publish_device_state(client, device, device_state); | ||||
| 	ASTOBJ_UNREF(client, aji_client_destroy); | ||||
| } | ||||
|  | ||||
| /*! | ||||
| @@ -3449,7 +3453,7 @@ static int aji_handle_pubsub_error(void *data, ikspak *pak) | ||||
| 	int error_num; | ||||
| 	iks *orig_request; | ||||
| 	iks *orig_pubsub = iks_find(pak->x, "pubsub"); | ||||
| 	struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); | ||||
| 	struct aji_client *client; | ||||
| 	if (!orig_pubsub) { | ||||
| 		ast_log(LOG_ERROR, "Error isn't a PubSub error, why are we here?\n"); | ||||
| 		return IKS_FILTER_EAT; | ||||
| @@ -3469,6 +3473,8 @@ static int aji_handle_pubsub_error(void *data, ikspak *pak) | ||||
| 		return IKS_FILTER_EAT; | ||||
| 	} | ||||
|  | ||||
| 	client = ASTOBJ_REF((struct aji_client *) data); | ||||
|  | ||||
| 	if (!strcasecmp(iks_name(orig_request), "publish")) { | ||||
| 		iks *request; | ||||
| 		if (ast_test_flag(&pubsubflags, AJI_XEP0248)) { | ||||
| @@ -3484,6 +3490,7 @@ static int aji_handle_pubsub_error(void *data, ikspak *pak) | ||||
| 		iks_insert_node(request, orig_pubsub); | ||||
| 		ast_aji_send(client, request); | ||||
| 		iks_delete(request); | ||||
| 		ASTOBJ_UNREF(client, aji_client_destroy); | ||||
| 		return IKS_FILTER_EAT; | ||||
| 	} else if (!strcasecmp(iks_name(orig_request), "subscribe")) { | ||||
| 		if (ast_test_flag(&pubsubflags, AJI_XEP0248)) { | ||||
| @@ -3492,7 +3499,7 @@ static int aji_handle_pubsub_error(void *data, ikspak *pak) | ||||
| 			aji_create_pubsub_node(client, NULL, node_name, NULL); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	ASTOBJ_UNREF(client, aji_client_destroy); | ||||
| 	return IKS_FILTER_EAT; | ||||
| } | ||||
|  | ||||
| @@ -3554,6 +3561,7 @@ static int aji_receive_node_list(void *data, ikspak* pak) | ||||
| 	if (item) { | ||||
| 		iks_delete(item); | ||||
| 	} | ||||
| 	ASTOBJ_UNREF(client, aji_client_destroy); | ||||
| 	return IKS_FILTER_EAT; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user