[Asterisk-code-review] RTP Engine: Deal with errors returned from AST VECTOR REPLACE. (asterisk[15])
Corey Farrell
asteriskteam at digium.com
Mon Nov 6 15:22:54 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7040
Change subject: RTP Engine: Deal with errors returned from AST_VECTOR_REPLACE.
......................................................................
RTP Engine: Deal with errors returned from AST_VECTOR_REPLACE.
Check for errors from AST_VECTOR_REPLACE and clean memory if needed.
Change-Id: I124d15cc1d645f85a72a1279f623c1993b304b0b
---
M main/rtp_engine.c
1 file changed, 17 insertions(+), 7 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/40/7040/1
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 0aed8e9..2431ffc 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -802,7 +802,10 @@
ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_rx, payload),
"cleaning up rx mapping vector element about to be replaced");
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type);
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type)) {
+ ao2_ref(new_type, -1);
+ return;
+ }
payload_mapping_rx_clear_primary(codecs, new_type);
}
@@ -924,7 +927,10 @@
ao2_t_cleanup(AST_VECTOR_GET(&dest->payload_mapping_tx, idx),
"cleaning up tx mapping vector element about to be replaced");
}
- AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type);
+ if (AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type)) {
+ ao2_ref(type, -1);
+ continue;
+ }
if (instance && instance->engine && instance->engine->payload_set) {
ao2_lock(instance);
@@ -1038,9 +1044,10 @@
ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload),
"cleaning up replaced tx payload type");
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type);
- if (instance && instance->engine && instance->engine->payload_set) {
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type)) {
+ ao2_ref(new_type, -1);
+ } else if (instance && instance->engine && instance->engine->payload_set) {
ao2_lock(instance);
instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code);
ao2_unlock(instance);
@@ -1116,9 +1123,10 @@
ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, pt),
"cleaning up replaced tx payload type");
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type);
- if (instance && instance->engine && instance->engine->payload_set) {
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type)) {
+ ao2_ref(new_type, -1);
+ } else if (instance && instance->engine && instance->engine->payload_set) {
ao2_lock(instance);
instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code);
ao2_unlock(instance);
@@ -1215,7 +1223,9 @@
if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
ao2_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload));
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type);
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type)) {
+ ao2_ref(type, -1);
+ }
} else {
ao2_ref(type, -1);
}
--
To view, visit https://gerrit.asterisk.org/7040
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I124d15cc1d645f85a72a1279f623c1993b304b0b
Gerrit-Change-Number: 7040
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/b6f7e72a/attachment.html>
More information about the asterisk-code-review
mailing list