[MPlayer-dev-eng] Re: [MPlayer-users] subtitle reader crashes on Solaris

D Richard Felker III dalias at aerifal.cx
Thu Jul 3 16:34:31 CEST 2003


On Thu, Jul 03, 2003 at 03:44:06PM +0200, Götz Waschk wrote:
> Am Mittwoch,  2. Juli 2003, 14:08:18 Uhr MET, schrieb Götz Waschk:
> > the subtitle reader that automatically tries to open a matching
> > subtitle file for your video, crashes on Solaris. This happens
> > everytime there is a .txt file in the same directory as the video
> > file.
> 
> OK,
> 
> I've found the problem, it's in subreader.c. On Solaris, you cannot
> pass a null pointer to sprintf, as in this code snippet:
> sprintf(tmpresult, "%s %s", f_fname_trim, tmp_sub_id);
> If tmp_sub_id is a null pointer, this causes a segmentation fault on
> Solaris. On Linux, the string (null) is generated instead. 
> 
> I've tried to emulate this with the attached patch, please take a
> look.
> 
> CU
> -- 
> What difference does it make to the dead, the orphans and the
> homeless, whether the mad destruction is wrought under the name of
> totalitarianism or the holy name of liberty or democracy?
>     Mahatma Gandhi (1869 - 1948), "Non-Violence in Peace and War"

> Index: subreader.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/subreader.c,v
> retrieving revision 1.112
> diff -u -r1.112 subreader.c
> --- subreader.c	1 Jul 2003 09:29:31 -0000	1.112
> +++ subreader.c	3 Jul 2003 13:43:12 -0000
> @@ -1686,7 +1686,10 @@
>  		// we have a (likely) subtitle file
>  		if (found) {
>  		    int prio = 0;
> -		    sprintf(tmpresult, "%s %s", f_fname_trim, tmp_sub_id);
> +		    if (tmp_sub_id)
> +		      sprintf(tmpresult, "%s %s", f_fname_trim, tmp_sub_id);
> +		    else
> +		      sprintf(tmpresult, "%s (null)", f_fname_trim);

Ever heard of: 'tmp_sub_id ? tmp_sub_id : "(null)"' ??

It's much cleaner and more readable.

Rich



More information about the MPlayer-dev-eng mailing list