[Asterisk-code-review] res_musiconhold: Don't crash when real-time doesn't return any entries (asterisk[16])
Nathan Bruning
asteriskteam at digium.com
Thu Dec 10 17:12:19 CST 2020
Nathan Bruning has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15212 )
Change subject: res_musiconhold: Don't crash when real-time doesn't return any entries
......................................................................
res_musiconhold: Don't crash when real-time doesn't return any entries
ASTERISK-29211 #close
Change-Id: Ifbf0a4f786ab2a52342f9d1a1db4c9907f069877
---
M res/res_musiconhold.c
1 file changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/15212/1
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index db7dde7..460536d 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1613,18 +1613,21 @@
char *category = NULL;
size_t entry_count = 0;
- while ((category = ast_category_browse(entries, category))) {
- const char *entry = ast_variable_retrieve(entries, category, "entry");
+ // entries is NULL if there are no results
+ if (entries != NULL) {
+ while ((category = ast_category_browse(entries, category))) {
+ const char *entry = ast_variable_retrieve(entries, category, "entry");
- if (entry) {
- struct ast_variable *dup = ast_variable_new("entry", entry, "");
- if (dup) {
- entry_count++;
- ast_variable_list_append(&var, dup);
+ if (entry) {
+ struct ast_variable *dup = ast_variable_new("entry", entry, "");
+ if (dup) {
+ entry_count++;
+ ast_variable_list_append(&var, dup);
+ }
}
}
+ ast_config_destroy(entries);
}
- ast_config_destroy(entries);
if (entry_count == 0) {
/* Behave as though this class doesn't exist */
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15212
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ifbf0a4f786ab2a52342f9d1a1db4c9907f069877
Gerrit-Change-Number: 15212
Gerrit-PatchSet: 1
Gerrit-Owner: Nathan Bruning <nathan at iperity.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20201210/c4a912d6/attachment.html>
More information about the asterisk-code-review
mailing list