[MPlayer-cvslog] r28215 - in trunk: DOCS/man/en/mplayer.1 libvo/vo_macosx.m

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Jan 1 10:58:23 CET 2009


On Tue, Dec 30, 2008 at 10:39:42PM +0100, gpoirier wrote:
>  static opt_t subopts[] = {
>  {"device_id",     OPT_ARG_INT,  &screen_id,     (opt_test_f)int_non_neg},
>  {"shared_buffer", OPT_ARG_BOOL, &shared_buffer, NULL},
> +{"buffer_name",   OPT_ARG_MSTRZ,&buffer_name,   NULL},
>  {NULL}
>  };
>  
> @@ -328,16 +337,21 @@ static int preinit(const char *arg)
>  	// set defaults
>  	screen_id = 0;
>  	shared_buffer = false;
> +	buffer_name = DEFAULT_BUFFER_NAME;

This is a wrong use of the API. "OPT_ARG_MSTRZ" is a malloced string,
and that variable may only ever contain a malloc string.
Either use strdup(DEFAULT_BUFFER_NAME) or set it to NULL and then after
subopt_parse check if it is NULL - which avoids the strcmp which makes
the code behave differently from the documentation anyway.

> @@ -347,6 +361,9 @@ static int preinit(const char *arg)
>  	NSApp = [NSApplication sharedApplication];
>  	isLeopardOrLater = floor(NSAppKitVersionNumber) > 824;
>  	
> +	if (strcmp(buffer_name, DEFAULT_BUFFER_NAME))
> +		shared_buffer = true;
> +	

Probably you should be doing
if (!buffer_name) {
    buffer_name = strdup(DEFAULT_BUFFER_NAME);
    shared_buffer = true;
}
then to avoid issues with the
free(buffer_name) in the code, as mentioned in
http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1370



More information about the MPlayer-cvslog mailing list