[pulseaudio-discuss] [PATCH v2 5/6] sink-input: Avoid potential NULL dereference

Peter Meerwald-Stadler pmeerw at pmeerw.net
Tue Aug 30 13:04:34 UTC 2016


if data->sink is NULL, pa_sink_input_new_data_set_sink() may fail to set data->sink;
the false retval is ignored, leading to a NULL dereference in pa_sink_get_state(data->sink) below

CID 1323591
---
 src/pulsecore/sink-input.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 0dda204..39e2e61 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -337,7 +337,7 @@ int pa_sink_input_new(
     if (!data->format && data->nego_formats && !pa_idxset_isempty(data->nego_formats))
         data->format = pa_format_info_copy(pa_idxset_first(data->nego_formats, NULL));
 
-    if (PA_LIKELY(data->format)) {
+    if (PA_LIKELY(data->format) && PA_LIKELY(data->sink)) {
         pa_log_debug("Negotiated format: %s", pa_format_info_snprint(fmt, sizeof(fmt), data->format));
     } else {
         pa_format_info *format;
-- 
1.7.10.4



More information about the pulseaudio-discuss mailing list