[Asterisk-code-review] res_prometheus: Do not crash on invisible bridges (asterisk[18])

Friendly Automation asteriskteam at digium.com
Tue Sep 27 06:16:09 CDT 2022


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19369 )

Change subject: res_prometheus: Do not crash on invisible bridges
......................................................................

res_prometheus: Do not crash on invisible bridges

Avoid crashing by skipping invisible bridges and checking the
snapshot for a null pointer. In effect this is how the bridges
are enumerated in res/ari/resource_bridges.c already.

ASTERISK-30239
ASTERISK-30237

Change-Id: I58ef9f44036feded5966b5fc70ae754f8182883d
---
M res/prometheus/bridges.c
1 file changed, 27 insertions(+), 1 deletion(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit




diff --git a/res/prometheus/bridges.c b/res/prometheus/bridges.c
index 5a91604..505dab8 100644
--- a/res/prometheus/bridges.c
+++ b/res/prometheus/bridges.c
@@ -125,7 +125,17 @@
 	/* Bridge dependent values */
 	it_bridges = ao2_iterator_init(bridges, 0);
 	for (i = 0; (bridge = ao2_iterator_next(&it_bridges)); ao2_ref(bridge, -1), i++) {
-		struct ast_bridge_snapshot *snapshot = ast_bridge_get_snapshot(bridge);
+		struct ast_bridge_snapshot *snapshot;
+
+		/* Invisible bridges don't get shown externally and have no snapshot */
+		if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_INVISIBLE)) {
+			continue;
+		}
+
+		snapshot = ast_bridge_get_snapshot(bridge);
+		if (!snapshot) {
+			continue;
+		}
 
 		for (j = 0; j < ARRAY_LEN(bridge_metric_defs); j++) {
 			int index = i * ARRAY_LEN(bridge_metric_defs) + j;

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19369
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: I58ef9f44036feded5966b5fc70ae754f8182883d
Gerrit-Change-Number: 19369
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Hans Peter Freyther <automatic at freyther.de>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220927/9d1a9031/attachment-0001.html>


More information about the asterisk-code-review mailing list