[MPlayer-cvslog] r27195 - trunk/stream/stream_dvd.c

Nico Sabbi nicola.sabbi at poste.it
Sun Jul 6 12:06:56 CEST 2008


Il giorno ven, 04/07/2008 alle 18.09 +0200, Mathieu SCHROETER ha
scritto:
> nicodvb a écrit :
> > @@ -781,13 +785,18 @@ static int open_s(stream_t *stream,int m
> >      /**
> >       * Open the disc.
> >       */
> > -    if(!dvd_device) dvd_device=strdup(DEFAULT_DVD_DEVICE);
> > -    dvd_set_speed(dvd_device, dvd_speed);
> > +    if(p->device)
> > +      dvd_device_current = p->device;
> > +    else if(dvd_device)
> > +      dvd_device_current = dvd_device;
> > +    else
> > +      dvd_device_current = strdup(DEFAULT_DVD_DEVICE);
> > +    dvd_set_speed(dvd_device_current, dvd_speed);
> 
> Hi,
> 
> if dvd_device is NULL and if you use "loadfile dvd://", then
> memory is allocated on dvd_device_current.
> and after you use "loadfile dvd:////dev/scd1" (for example)
> then dvd_device_current will use p->device and previous
> allocated memory is _lost_.
> 
> My suggestion was:
> 
>   if(!p->device) {
>     if(!dvd_device)
>       dvd_device = strdup(DEFAULT_DVD_DEVICE);
>     dvd_device_current = dvd_device;
>   } else
>     dvd_device_current = p->device;
> 
> and malloc is only used on dvd_device (no memleak with
> dvd_device_current)..
> 
> Regards,
> Mathieu
> 

what about this? simpler and nicer to read IMO
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d.diff
Type: text/x-patch
Size: 789 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-cvslog/attachments/20080706/f0a1e1ad/attachment.bin>


More information about the MPlayer-cvslog mailing list