[Asterisk-code-review] RTP Engine: Deal with errors returned from AST VECTOR REPLACE. (asterisk[master])
Joshua Colp
asteriskteam at digium.com
Tue Nov 7 06:36:33 CST 2017
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/7039 )
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(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
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/7039
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I124d15cc1d645f85a72a1279f623c1993b304b0b
Gerrit-Change-Number: 7039
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171107/74a1c4c1/attachment.html>
More information about the asterisk-code-review
mailing list