]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Messaging: Report error on failure to register tech or handler.
authorCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 21:10:56 +0000 (16:10 -0500)
committerCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 21:13:58 +0000 (16:13 -0500)
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

index be0035d30d4c802473209be94db36f6390486b54..caee37c8111954fc6b44c263012f13a44ee6cc40 100644 (file)
@@ -1364,7 +1364,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);
@@ -1419,7 +1424,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);