[vlc-devel] [PATCH] es_out: check p_pgrm before checking visibility

Alexandre Janniaux ajanni at videolabs.io
Mon Mar 23 11:03:22 CET 2020


If EsOutProgramDel is called before EsOutProgramAdd with the program
being currently selected, EsOutProgramAdd will call
EsOutProgramIsVisible with p_sys->p_pgrm == NULL and accessing source
just below will lead to UB/crash.

Regression from 8c9623b6c92a94191afdb7082f3a4bd5ea4995f0.

Note that the behaviour is slightly different from the previous
behaviour, as it will now return false if no program is selected.

Co-authored-by: Thomas Guillem <thomas at gllm.fr>
---
 src/input/es_out.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index d6fa3e41e7..8d45a6c2c8 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1250,6 +1250,10 @@ static inline bool EsOutIsGroupSticky( es_out_t *p_out, input_source_t *source,
 static bool EsOutIsProgramVisible( es_out_t *out, input_source_t *source, int i_group )
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
+
+    if (p_sys->p_pgrm == NULL)
+        return false;
+
     return p_sys->i_group_id == 0
         || (p_sys->i_group_id == i_group && p_sys->p_pgrm->source == source);
 }
-- 
2.25.2



More information about the vlc-devel mailing list