[MPlayer-cvslog] CVS: main/libmpdemux muxer_lavf.c,1.23,1.24

Rich Felker dalias at aerifal.cx
Sun Mar 12 22:53:24 CET 2006


On Sun, Mar 12, 2006 at 10:09:34PM +0100, Michael Niedermayer wrote:
> Hi
> 
> On Sun, Mar 12, 2006 at 07:06:48PM +0100, Nico Sabbi CVS wrote:
> > CVS change done by Nico Sabbi CVS
> > 
> > Update of /cvsroot/mplayer/main/libmpdemux
> > In directory mail:/var2/tmp/cvs-serv27377
> > 
> > Modified Files:
> > 	muxer_lavf.c 
> > Log Message:
> > fixed C99-ism introduced with previous commit
> > 
> > Index: muxer_lavf.c
> > ===================================================================
> > RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_lavf.c,v
> > retrieving revision 1.23
> > retrieving revision 1.24
> > diff -u -r1.23 -r1.24
> > --- muxer_lavf.c	12 Mar 2006 17:46:51 -0000	1.23
> > +++ muxer_lavf.c	12 Mar 2006 18:06:46 -0000	1.24
> > @@ -103,17 +103,17 @@
> >  
> >  static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type)
> >  {
> > -	if(!muxer) return NULL;
> > -	muxer_priv_t *priv = (muxer_priv_t*) muxer->priv;
> > +	muxer_priv_t *priv;
> >  	muxer_stream_t *stream;
> >  	muxer_stream_priv_t *spriv;
> >  	AVCodecContext *ctx;
> >  
> > -	if(type != MUXER_TYPE_VIDEO && type != MUXER_TYPE_AUDIO) 
> > +	if(!muxer || (type != MUXER_TYPE_VIDEO && type != MUXER_TYPE_AUDIO))
> >  	{
> > -		mp_msg(MSGT_MUXER, MSGL_ERR, "UNKNOW TYPE %d\n", type);
> > +		mp_msg(MSGT_MUXER, MSGL_ERR, "NULL MUXER PASSED OR UNKNOW TYPE %d\n", type);
> >  		return NULL;
> >  	}
> > +	priv = (muxer_priv_t*) muxer->priv;
> 
> reverse this shit and the previous commit
> 
> the correct fix for the "null check after use" issue coverity found is to
> remove the null check or put a assert(muxer) there, if you would have
> looked at the code instead randomly changeing it to hide as 
> many coverity warnings as quick as possible then you would have noticed
> that the theres a check for muxer being NULL before the 2 calls to
> lavf_new_stream()
> 
> yeah fixing warnings that way is going to add more bugs then the code
> had to begin with

OK, I agree now.. IMO removing the null check entirely is best.

Rich




More information about the MPlayer-cvslog mailing list