diff --git a/main/message.c b/main/message.c
index 7098f698d0e97a6fd7f23f3322a87a3a0833740d..54c604c47d26b8205f96d5b259952d86f230475a 100644
--- a/main/message.c
+++ b/main/message.c
@@ -398,7 +398,7 @@ static void msg_destructor(void *obj)
 	struct ast_msg *msg = obj;
 
 	ast_string_field_free_memory(msg);
-	ao2_ref(msg->vars, -1);
+	ao2_cleanup(msg->vars);
 }
 
 struct ast_msg *ast_msg_alloc(void)
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 20d1f9d99317f63b6513539c577f5a69f6ad20dd..f72f3f01548f45f600d1cbe7959b3e3940fe4cff 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -601,7 +601,7 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f
 
 	if (!(mdata = msg_data_create(msg, to, from)) ||
 	    ast_sip_push_task(message_serializer, msg_send, mdata)) {
-		ao2_ref(mdata, -1);
+		ao2_cleanup(mdata);
 		return -1;
 	}
 	return 0;