[asterisk-commits] gtjoseph: trunk r408521 - in /trunk: ./ main/config.c res/res_pjsip/pjsip_cli.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 20 15:04:33 CST 2014
Author: gtjoseph
Date: Thu Feb 20 15:04:28 2014
New Revision: 408521
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408521
Log:
pjsip_cli: Fix memory leak in ast_sip_cli_print_sorcery_objectset.
Fixed memory leaks in ast_sip_cli_print_sorcery_objectset and
ast_variable_list_sort.
(closes issue ASTERISK-23266)
Review: http://reviewboard.asterisk.org/r/3200/
........
Merged revisions 408520 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/main/config.c
trunk/res/res_pjsip/pjsip_cli.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/main/config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/config.c?view=diff&rev=408521&r1=408520&r2=408521
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Thu Feb 20 15:04:28 2014
@@ -596,19 +596,19 @@
struct ast_variable *ast_variable_list_sort(struct ast_variable *start)
{
- struct ast_variable *p, *q, *top;
+ struct ast_variable *p, *q;
+ struct ast_variable top;
int changed = 1;
- top = ast_calloc(1, sizeof(struct ast_variable));
- top->next = start;
+ memset(&top, 0, sizeof(top));
+ top.next = start;
if (start != NULL && start->next != NULL) {
while (changed) {
changed = 0;
- q = top;
- p = top->next;
+ q = ⊤
+ p = top.next;
while (p->next != NULL) {
if (p->next != NULL && strcmp(p->name, p->next->name) > 0) {
q->next = variable_list_switch(p, p->next);
-
changed = 1;
}
q = p;
@@ -617,7 +617,7 @@
}
}
}
- return top->next;
+ return top.next;
}
const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Modified: trunk/res/res_pjsip/pjsip_cli.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/pjsip_cli.c?view=diff&rev=408521&r1=408520&r2=408521
==============================================================================
--- trunk/res/res_pjsip/pjsip_cli.c (original)
+++ trunk/res/res_pjsip/pjsip_cli.c Thu Feb 20 15:04:28 2014
@@ -71,9 +71,8 @@
}
}
- if (!(separator = alloca(max_name_width + max_value_width + 8))) {
- return -1;
- }
+ separator = ast_alloca(max_name_width + max_value_width + 8);
+
memset(separator, '=', max_name_width + max_value_width + 3);
separator[max_name_width + max_value_width + 3] = 0;
@@ -85,6 +84,8 @@
for (i = objset; i; i = i->next) {
ast_str_append(&context->output_buffer, 0, " %-*s : %s\n", max_name_width, i->name, i->value);
}
+
+ ast_variables_destroy(objset);
return 0;
}
More information about the asterisk-commits
mailing list