diff --git a/main/xmldoc.c b/main/xmldoc.c
index 71def2aa3c6d08c0edd22058bfcb01a611df47bd..2dd343263290e9a0fc015baf929b4fb3dc2e47a7 100644
--- a/main/xmldoc.c
+++ b/main/xmldoc.c
@@ -2475,10 +2475,11 @@ struct ao2_container *ast_xmldoc_build_documentation(const char *type)
 			case CONFIG_INFO_SYNTAX:
 			{
 				struct ast_xml_doc_item *tail;
+				RAII_VAR(const char *, name, ast_xml_get_attribute(node, "name"), ast_xml_free_attr);
 				if (item || !ast_xml_node_get_children(node) || strcasecmp(ast_xml_node_get_name(node), "configInfo")) {
 					break;
 				}
-				if (!(item = xmldoc_build_documentation_item(node, ast_xml_get_attribute(node, "name"), "configInfo"))) {
+				if (!(item = xmldoc_build_documentation_item(node, name, "configInfo"))) {
 					break;
 				}
 				tail = item;