[vlc-commits] filters: don't allow a NULL operations structure

Steve Lhomme git at videolan.org
Thu Oct 8 10:28:18 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Oct  6 10:07:01 2020 +0200| [4a97123ad7b7911653361e831b35ae08a2b23bcb] | committer: Steve Lhomme

filters: don't allow a NULL operations structure

Filters created with aout_filter_Create() already check the structure pointer
is not NULL.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a97123ad7b7911653361e831b35ae08a2b23bcb
---

 include/vlc_filter.h                  | 6 +++---
 modules/access/screen/screen.c        | 1 +
 modules/audio_filter/scaletempo.c     | 1 +
 modules/hw/d3d11/d3d11_surface.c      | 1 +
 modules/hw/d3d9/dxa9.c                | 1 +
 modules/video_filter/blendbench.c     | 1 +
 modules/video_filter/ci_filters.m     | 1 +
 modules/video_filter/opencv_wrapper.c | 2 +-
 src/misc/filter.c                     | 1 +
 src/misc/filter_chain.c               | 1 +
 src/misc/image.c                      | 1 +
 src/video_output/vout_subpictures.c   | 2 ++
 12 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 0ced8ea03d..772f58dee9 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -203,14 +203,14 @@ static inline picture_t *filter_NewPicture( filter_t *p_filter )
  */
 static inline void filter_Flush( filter_t *p_filter )
 {
-    if( p_filter->ops && p_filter->ops->flush != NULL )
+    if( p_filter->ops->flush != NULL )
         p_filter->ops->flush( p_filter );
 }
 
 static inline void filter_ChangeViewpoint( filter_t *p_filter,
                                            const vlc_viewpoint_t *vp)
 {
-    if( p_filter->ops && p_filter->ops->change_viewpoint != NULL )
+    if( p_filter->ops->change_viewpoint != NULL )
         p_filter->ops->change_viewpoint( p_filter, vp );
 }
 
@@ -244,7 +244,7 @@ static inline vlc_decoder_device * filter_HoldDecoderDeviceType( filter_t *p_fil
  */
 static inline block_t *filter_DrainAudio( filter_t *p_filter )
 {
-    if( p_filter->ops && p_filter->ops->drain_audio )
+    if( p_filter->ops->drain_audio )
         return p_filter->ops->drain_audio( p_filter );
     else
         return NULL;
diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c
index fda1417eb0..518697f700 100644
--- a/modules/access/screen/screen.c
+++ b/modules/access/screen/screen.c
@@ -385,6 +385,7 @@ void RenderCursor( demux_t *p_demux, int i_x, int i_y,
                 vlc_object_delete(p_sys->p_blend);
                 p_sys->p_blend = NULL;
             }
+            assert( p_sys->p_blend->ops != NULL );
         }
     }
     if( p_sys->p_blend )
diff --git a/modules/audio_filter/scaletempo.c b/modules/audio_filter/scaletempo.c
index 18f8a30d10..1616ce59d3 100644
--- a/modules/audio_filter/scaletempo.c
+++ b/modules/audio_filter/scaletempo.c
@@ -493,6 +493,7 @@ static filter_t *ResamplerCreate(filter_t *p_filter)
         vlc_object_delete(p_resampler);
         return NULL;
     }
+    assert( p_resampler->ops != NULL );
     return p_resampler;
 }
 
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index f3fe4ddbd4..07d3b71522 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -509,6 +509,7 @@ static filter_t *CreateCPUtoGPUFilter( filter_t *p_this, const es_format_t *p_fm
         DeleteFilter( p_filter );
         return NULL;
     }
+    assert( p_filter->ops != NULL );
 
     return p_filter;
 }
diff --git a/modules/hw/d3d9/dxa9.c b/modules/hw/d3d9/dxa9.c
index afb484895d..621d4af670 100644
--- a/modules/hw/d3d9/dxa9.c
+++ b/modules/hw/d3d9/dxa9.c
@@ -217,6 +217,7 @@ static filter_t *CreateFilter( filter_t *p_this, const es_format_t *p_fmt_in,
         DeleteFilter( p_filter );
         return NULL;
     }
+    assert( p_filter->ops != NULL );
 
     return p_filter;
 }
diff --git a/modules/video_filter/blendbench.c b/modules/video_filter/blendbench.c
index 0a6c17ad22..ce45124968 100644
--- a/modules/video_filter/blendbench.c
+++ b/modules/video_filter/blendbench.c
@@ -253,6 +253,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         vlc_object_delete(p_blend);
         return NULL;
     }
+    assert( p_blend->ops != NULL );
 
     vlc_tick_t time = vlc_tick_now();
     for( int i_iter = 0; i_iter < p_sys->i_loops; ++i_iter )
diff --git a/modules/video_filter/ci_filters.m b/modules/video_filter/ci_filters.m
index 4bc46be346..7374393c25 100644
--- a/modules/video_filter/ci_filters.m
+++ b/modules/video_filter/ci_filters.m
@@ -565,6 +565,7 @@ CVPX_to_CVPX_converter_Create(filter_t *filter, bool to_rgba)
         vlc_object_delete(converter);
         return NULL;
     }
+    assert( converter->ops != NULL );
 
     return converter;
 }
diff --git a/modules/video_filter/opencv_wrapper.c b/modules/video_filter/opencv_wrapper.c
index d103cc7edc..6e92e8b143 100644
--- a/modules/video_filter/opencv_wrapper.c
+++ b/modules/video_filter/opencv_wrapper.c
@@ -187,7 +187,7 @@ static int Create( vlc_object_t *p_this )
 
         return VLC_ENOMOD;
     }
-
+    assert( p_sys->p_opencv->ops != NULL );
 
     /* Init structure */
     p_sys->p_image = image_HandlerCreate( p_filter );
diff --git a/src/misc/filter.c b/src/misc/filter.c
index ed23e1d7fe..ace08e2329 100644
--- a/src/misc/filter.c
+++ b/src/misc/filter.c
@@ -154,6 +154,7 @@ int filter_ConfigureBlend( vlc_blender_t *p_blend,
         p_blend->p_module = module_need( p_blend, "video blending", NULL, false );
     if( !p_blend->p_module )
         return VLC_EGENERIC;
+    assert( p_blend->ops != NULL );
     return VLC_SUCCESS;
 }
 
diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 29d7509a96..a97e2de4ae 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -260,6 +260,7 @@ static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
 
     if( filter->p_module == NULL )
         goto error;
+    assert( filter->ops != NULL );
 
     if( chain->last == NULL )
     {
diff --git a/src/misc/image.c b/src/misc/image.c
index e8f508c66b..c340d0d9aa 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -808,6 +808,7 @@ static filter_t *CreateConverter( vlc_object_t *p_this,
         DeleteConverter( p_filter );
         return NULL;
     }
+    assert( p_filter->ops != NULL );
 
     return p_filter;
 }
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index fefcf21b8e..8c7af5e387 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -272,6 +272,7 @@ static filter_t *SpuRenderCreateAndLoadText(spu_t *spu)
         vlc_object_delete(text);
         return NULL;
     }
+    assert( text->ops != NULL );
 
     return text;
 }
@@ -305,6 +306,7 @@ static filter_t *SpuRenderCreateAndLoadScale(vlc_object_t *object,
         vlc_object_delete(scale);
         return NULL;
     }
+    assert( scale->ops != NULL );
 
     return scale;
 }



More information about the vlc-commits mailing list