From 32a0567c461ee426817e476724e206d603fe1e70 Mon Sep 17 00:00:00 2001
From: Matthew Jordan <mjordan@digium.com>
Date: Fri, 23 Aug 2013 18:02:36 +0000
Subject: [PATCH] Prevent seg fault in off nominal path when registered option
 fails to validate

If an option is registered to a type and it is the last known type in the list
of registered types, and the option fails to register, an overrun of the types
array can occur due to the index variable having been already incremented.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397568 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/config_options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main/config_options.c b/main/config_options.c
index 20e9935074..37c743355e 100644
--- a/main/config_options.c
+++ b/main/config_options.c
@@ -188,7 +188,7 @@ static int link_option_to_types(struct aco_info *info, struct aco_type **types,
 #endif /* AST_XML_DOCS */
 		) {
 			do {
-				ao2_unlink(types[idx]->internal->opts, opt);
+				ao2_unlink(types[idx - 1]->internal->opts, opt);
 			} while (--idx);
 			return -1;
 		}
-- 
GitLab