[Asterisk-code-review] res pjsip history: Fix multiple leaks on vector append failure. (asterisk[13])
Corey Farrell
asteriskteam at digium.com
Tue Nov 7 11:10:56 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7100
Change subject: res_pjsip_history: Fix multiple leaks on vector append failure.
......................................................................
res_pjsip_history: Fix multiple leaks on vector append failure.
Change-Id: I41e8d5183ace284095cc721f3b1fb32ade3f940f
---
M res/res_pjsip_history.c
1 file changed, 20 insertions(+), 6 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/7100/1
diff --git a/res/res_pjsip_history.c b/res/res_pjsip_history.c
index 0b50f68..fef3bbc 100644
--- a/res/res_pjsip_history.c
+++ b/res/res_pjsip_history.c
@@ -707,10 +707,13 @@
pj_sockaddr_cp(&entry->dst, &tdata->tp_info.dst_addr);
ast_mutex_lock(&history_lock);
- AST_VECTOR_APPEND(&vector_history, entry);
+ if (AST_VECTOR_APPEND(&vector_history, entry)) {
+ ao2_ref(entry, -1);
+ entry = NULL;
+ }
ast_mutex_unlock(&history_lock);
- if (log_level != -1) {
+ if (log_level != -1 && entry) {
char line[256];
sprint_list_entry(entry, line, sizeof(line));
@@ -747,7 +750,10 @@
}
ast_mutex_lock(&history_lock);
- AST_VECTOR_APPEND(&vector_history, entry);
+ if (AST_VECTOR_APPEND(&vector_history, entry)) {
+ ao2_ref(entry, -1);
+ entry = NULL;
+ }
ast_mutex_unlock(&history_lock);
if (log_level != -1) {
@@ -961,7 +967,9 @@
/* If this is not an operator, push it to the stack */
if (!it_queue->op) {
- AST_VECTOR_APPEND(&stack, it_queue);
+ if (AST_VECTOR_APPEND(&stack, it_queue)) {
+ goto error;
+ }
continue;
}
@@ -1037,7 +1045,11 @@
if (!result) {
goto error;
}
- AST_VECTOR_APPEND(&stack, result);
+ if (AST_VECTOR_APPEND(&stack, result)) {
+ expression_token_free(result);
+
+ goto error;
+ }
}
/*
@@ -1120,7 +1132,9 @@
} else if (!res) {
continue;
} else {
- AST_VECTOR_APPEND(output, ao2_bump(entry));
+ if (AST_VECTOR_APPEND(output, ao2_bump(entry))) {
+ ao2_cleanup(entry);
+ }
}
}
ast_mutex_unlock(&history_lock);
--
To view, visit https://gerrit.asterisk.org/7100
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I41e8d5183ace284095cc721f3b1fb32ade3f940f
Gerrit-Change-Number: 7100
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/20171107/50cffd7e/attachment.html>
More information about the asterisk-code-review
mailing list