From 66d7c8495ab9bc9c9f67822f941684f79607b1f8 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Mon, 6 Nov 2017 16:10:56 -0500 Subject: Messaging: Report error on failure to register tech or handler. Message tech and handler registrations use a vector which could fail to expand. If it does log and error and return error. Change-Id: I593a8de81a07fb0452e9b0efd5d4018b77bca6f4 --- main/message.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'main/message.c') diff --git a/main/message.c b/main/message.c index fcdf705fe..ac7965ea7 100644 --- a/main/message.c +++ b/main/message.c @@ -1362,7 +1362,12 @@ int ast_msg_tech_register(const struct ast_msg_tech *tech) return -1; } - AST_VECTOR_APPEND(&msg_techs, tech); + if (AST_VECTOR_APPEND(&msg_techs, tech)) { + ast_log(LOG_ERROR, "Failed to register message technology for '%s'\n", + tech->name); + ast_rwlock_unlock(&msg_techs_lock); + return -1; + } ast_verb(3, "Message technology '%s' registered.\n", tech->name); ast_rwlock_unlock(&msg_techs_lock); @@ -1417,7 +1422,12 @@ int ast_msg_handler_register(const struct ast_msg_handler *handler) return -1; } - AST_VECTOR_APPEND(&msg_handlers, handler); + if (AST_VECTOR_APPEND(&msg_handlers, handler)) { + ast_log(LOG_ERROR, "Failed to register message handler for '%s'\n", + handler->name); + ast_rwlock_unlock(&msg_handlers_lock); + return -1; + } ast_verb(2, "Message handler '%s' registered.\n", handler->name); ast_rwlock_unlock(&msg_handlers_lock); -- cgit v1.2.3