[Asterisk-code-review] Messaging: Report error on failure to register tech or handler. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Mon Nov 6 15:13:33 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7034


Change subject: Messaging: Report error on failure to register tech or handler.
......................................................................

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
---
M main/message.c
1 file changed, 12 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/34/7034/1

diff --git a/main/message.c b/main/message.c
index fcdf705..ac7965e 100644
--- a/main/message.c
+++ b/main/message.c
@@ -1362,7 +1362,12 @@
 		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 @@
 		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);

-- 
To view, visit https://gerrit.asterisk.org/7034
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I593a8de81a07fb0452e9b0efd5d4018b77bca6f4
Gerrit-Change-Number: 7034
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171106/4d9ebac9/attachment.html>


More information about the asterisk-code-review mailing list