[MPlayer-dev-eng] [PATCH] Fix deinit problem due to r28215 (was Re: [MPlayer-cvslog] r28215 - in trunk: DOCS/man/en/mplayer.1 libvo/vo_macosx.m)
Guillaume POIRIER
poirierg at gmail.com
Fri Jan 2 22:00:14 CET 2009
Hello,
On Thu, Jan 1, 2009 at 10:58 AM, Reimar Döffinger
<Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> 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
Good catch!
How's that patch
--
Only a very small fraction of our DNA does anything; the rest is all
comments and ifdefs.
G. Gordon Liddy - "Obviously crime pays, or there'd be no crime."
then?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: buffer_name_is_on_heap.diff
Type: application/octet-stream
Size: 791 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20090102/b8ba2163/attachment.obj>
More information about the MPlayer-dev-eng
mailing list