[vlc-devel] [PATCH] csa: do not handle impossible NULL argument
Steve Lhomme
robux4 at ycbcr.xyz
Thu Dec 3 10:14:49 CET 2020
p_sys->csa in ts.c can be NULL (see csaSetup()) and the ts code will
work fine. So the NULL case is very much used (and I believe the common
case).
On 2020-12-02 20:46, remi at remlab.net wrote:
> From: RĂ©mi Denis-Courmont <remi at remlab.net>
>
> ---
> modules/mux/mpeg/csa.c | 6 +++---
> modules/mux/mpeg/csa.h | 2 +-
> modules/mux/mpeg/ts.c | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/modules/mux/mpeg/csa.c b/modules/mux/mpeg/csa.c
> index 19c2d6ad93..e6363cd965 100644
> --- a/modules/mux/mpeg/csa.c
> +++ b/modules/mux/mpeg/csa.c
> @@ -26,6 +26,7 @@
> # include "config.h"
> #endif
>
> +#include <assert.h>
> #include <vlc_common.h>
>
> #include "csa.h"
> @@ -124,15 +125,14 @@ int csa_SetCW( vlc_object_t *p_caller, csa_t *c, char *psz_ck, bool set_odd )
> /*****************************************************************************
> * csa_UseKey:
> *****************************************************************************/
> -int csa_UseKey( vlc_object_t *p_caller, csa_t *c, bool use_odd )
> +void csa_UseKey( vlc_object_t *p_caller, csa_t *c, bool use_odd )
> {
> - if ( !c ) return VLC_ENOOBJ;
> + assert(c != NULL);
> c->use_odd = use_odd;
> #ifndef TS_NO_CSA_CK_MSG
> msg_Dbg( p_caller, "using the %s key for scrambling",
> use_odd ? "odd" : "even" );
> #endif
> - return VLC_SUCCESS;
> }
>
> /*****************************************************************************
> diff --git a/modules/mux/mpeg/csa.h b/modules/mux/mpeg/csa.h
> index bbe13c5985..7badc3823c 100644
> --- a/modules/mux/mpeg/csa.h
> +++ b/modules/mux/mpeg/csa.h
> @@ -35,7 +35,7 @@ csa_t *csa_New( void );
> void csa_Delete( csa_t * );
>
> int csa_SetCW( vlc_object_t *p_caller, csa_t *c, char *psz_ck, bool odd );
> -int csa_UseKey( vlc_object_t *p_caller, csa_t *, bool use_odd );
> +void csa_UseKey( vlc_object_t *p_caller, csa_t *, bool use_odd );
>
> void csa_Decrypt( csa_t *, uint8_t *pkt, int i_pkt_size );
> void csa_Encrypt( csa_t *, uint8_t *pkt, int i_pkt_size );
> diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
> index d52289a325..569735541b 100644
> --- a/modules/mux/mpeg/ts.c
> +++ b/modules/mux/mpeg/ts.c
> @@ -828,10 +828,10 @@ static int ActiveKeyCallback( vlc_object_t *p_this, char const *psz_cmd,
> return VLC_EBADVAR;
>
> vlc_mutex_lock( &p_sys->csa_lock );
> - i_res = csa_UseKey( p_this, p_sys->csa, use_odd );
> + csa_UseKey( p_this, p_sys->csa, use_odd );
> vlc_mutex_unlock( &p_sys->csa_lock );
>
> - return i_res;
> + return VLC_SUCCESS;
> }
>
> /*****************************************************************************
> --
> 2.29.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list