Commit 775cc9aa authored by Cheng Sun's avatar Cheng Sun Committed by Jean-Baptiste Kempf

Psyche/sharpen: Add chroma checks to prevent crashes

or malfunctionning filters
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit f15ce264)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 34bb811d
...@@ -84,6 +84,13 @@ static int Create( vlc_object_t *p_this ) ...@@ -84,6 +84,13 @@ static int Create( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
const vlc_fourcc_t fourcc = p_filter->fmt_in.video.i_chroma;
const vlc_chroma_description_t *p_chroma = vlc_fourcc_GetChromaDescription( fourcc );
if( !p_chroma || p_chroma->plane_count != 3 || p_chroma->pixel_size != 1 ) {
msg_Err( p_filter, "Unsupported chroma (%4.4s)", (char*)&fourcc );
return VLC_EGENERIC;
}
/* Allocate structure */ /* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL ) if( p_filter->p_sys == NULL )
......
...@@ -117,6 +117,13 @@ static int Create( vlc_object_t *p_this ) ...@@ -117,6 +117,13 @@ static int Create( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
const vlc_fourcc_t fourcc = p_filter->fmt_in.video.i_chroma;
const vlc_chroma_description_t *p_chroma = vlc_fourcc_GetChromaDescription( fourcc );
if( !p_chroma || p_chroma->plane_count != 3 || p_chroma->pixel_size != 1 ) {
msg_Err( p_filter, "Unsupported chroma (%4.4s)", (char*)&fourcc );
return VLC_EGENERIC;
}
/* Allocate structure */ /* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL ) if( p_filter->p_sys == NULL )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment