virtual sources and sinks: Fix possible segfault

Several virtual sources and sinks apart from module-echo-cancel also query the master
sink or source to estimate the current latency. Those modules might potentially show
the bug that is described for module-echo-cancel in bug 100277.

This patch checks in the message handlers for the PA_{SINK,SOURCE}_MESSAGE_GET_LATENCY
if the master sink or source is valid and returns 0 as latency if not. This is however
not yet sufficient to solve the issue. Additional patches will follow.
This commit is contained in:
Georg Chini 2017-04-24 20:31:54 +02:00
parent 3bb94c4e83
commit db4fbb0121
6 changed files with 12 additions and 6 deletions

View file

@ -347,7 +347,8 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
* make sure we don't access it in that time. Also, the
* sink input is first shut down, the sink second. */
if (!PA_SINK_IS_LINKED(u->sink->thread_info.state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state)) {
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state) ||
!u->sink_input->sink) {
*((int64_t*) data) = 0;
return 0;
}

View file

@ -83,7 +83,8 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
/* The sink is _put() before the sink input is, so let's
* make sure we don't access it yet */
if (!PA_SINK_IS_LINKED(u->sink->thread_info.state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state)) {
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state) ||
!u->sink_input->sink) {
*((int64_t*) data) = 0;
return 0;
}

View file

@ -91,7 +91,8 @@ static int source_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t
* make sure we don't access it in that time. Also, the
* source output is first shut down, the source second. */
if (!PA_SOURCE_IS_LINKED(u->source->thread_info.state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state)) {
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state) ||
!u->source_output->source) {
*((int64_t*) data) = 0;
return 0;
}

View file

@ -94,7 +94,8 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
* make sure we don't access it in that time. Also, the
* sink input is first shut down, the sink second. */
if (!PA_SINK_IS_LINKED(u->sink->thread_info.state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state)) {
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state) ||
!u->sink_input->sink) {
*((int64_t*) data) = 0;
return 0;
}

View file

@ -175,7 +175,8 @@ static int source_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t
* make sure we don't access it in that time. Also, the
* source output is first shut down, the source second. */
if (!PA_SOURCE_IS_LINKED(u->source->thread_info.state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state)) {
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state) ||
!u->source_output->source) {
*((pa_usec_t*) data) = 0;
return 0;
}

View file

@ -122,7 +122,8 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
* make sure we don't access it in that time. Also, the
* sink input is first shut down, the sink second. */
if (!PA_SINK_IS_LINKED(u->sink->thread_info.state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state)) {
!PA_SINK_INPUT_IS_LINKED(u->sink_input->thread_info.state) ||
!u->sink_input->sink) {
*((int64_t*) data) = 0;
return 0;
}