[Core] Fix switch_event_base_add_header leaking memory when headers are with indexes. Add a unit-test.
* [Unit-tests] Add a test provoking switch_event_add_header to memory leak. * [Core] Fix switch_event_base_add_header leaking memory when headers are with indexes.
This commit is contained in:
parent
3c6ffc146f
commit
0fdd5b6727
|
@ -484,11 +484,14 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st
|
||||||
exists = 1;
|
exists = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FREE(data);
|
||||||
goto redraw;
|
goto redraw;
|
||||||
}
|
}
|
||||||
} else if (tmp_header) {
|
} else if (tmp_header) {
|
||||||
free_header(&tmp_header);
|
free_header(&tmp_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FREE(data);
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
if ((stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT)) {
|
if ((stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT)) {
|
||||||
|
|
|
@ -1062,11 +1062,14 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
|
||||||
exists = 1;
|
exists = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FREE(data);
|
||||||
goto redraw;
|
goto redraw;
|
||||||
}
|
}
|
||||||
} else if (tmp_header) {
|
} else if (tmp_header) {
|
||||||
free_header(&tmp_header);
|
free_header(&tmp_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FREE(data);
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
if ((stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
|
if ((stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
|
||||||
|
|
|
@ -51,6 +51,22 @@ FST_CORE_BEGIN("./conf")
|
||||||
}
|
}
|
||||||
FST_TEARDOWN_END()
|
FST_TEARDOWN_END()
|
||||||
|
|
||||||
|
FST_TEST_BEGIN(test_switch_event_add_header_leak)
|
||||||
|
{
|
||||||
|
switch_event_t* event;
|
||||||
|
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_CALLSTATE) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-State-Number[0]", "1");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_CALLSTATE) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-State-Number[5000]", "12");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FST_TEST_END()
|
||||||
|
|
||||||
FST_TEST_BEGIN(test_xml_free_attr)
|
FST_TEST_BEGIN(test_xml_free_attr)
|
||||||
{
|
{
|
||||||
switch_xml_t parent_xml = switch_xml_new("xml");
|
switch_xml_t parent_xml = switch_xml_new("xml");
|
||||||
|
|
Loading…
Reference in New Issue