[FFmpeg-devel] [PATCH] fix small memleak in rdt.c

Michael Niedermayer michaelni
Fri Nov 14 22:48:14 CET 2008


On Fri, Nov 14, 2008 at 03:17:26PM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> $subj.
> 

> Sidenote: if url_open_buf() allocates, shouldn't url_close_buf() free
> it? That doesn't appear to be the case right now, hence my confusion
> when I originally implemented this... Maybe the API should be renamed
> or something? Or a comment in the API docs?

id say mark both as deprecated and put them under #if VERSION < X
close is unused, open is just used by ffserver.c


> 
> Ronald

> Index: ffmpeg-svn/libavformat/rdt.c
> ===================================================================
> --- ffmpeg-svn.orig/libavformat/rdt.c	2008-11-14 15:00:17.000000000 -0500
> +++ ffmpeg-svn/libavformat/rdt.c	2008-11-14 15:00:30.000000000 -0500
> @@ -115,7 +115,7 @@
>  static int
>  rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
>  {
> -    ByteIOContext *pb;
> +    ByteIOContext pb;
>      int size;
>      uint32_t tag;
>  
> @@ -135,35 +135,36 @@
>       */
>      if (!rdt->mlti_data)
>          return -1;
> -    url_open_buf(&pb, rdt->mlti_data, rdt->mlti_data_size, URL_RDONLY);
> -    tag = get_le32(pb);
> +    init_put_byte(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
> +                  NULL, NULL, NULL, NULL);
[...]
> -    url_close_buf(pb);
> +    url_close_buf(&pb);

this isnt intended to stay or?


>      return 0;
>  }
>  
> @@ -250,32 +251,33 @@
>                    const uint8_t *buf, int len, int flags)
>  {
>      int seq = 1, res;
> -    ByteIOContext *pb = rdt->rmctx->pb;
> +    ByteIOContext pb;
[...]
> +        rdt->rmctx->pb = &pb;

you know that pb is on the stack and this stores it in a context that i
do not know if it might live longer than the local variables ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081114/157d41f8/attachment.pgp>



More information about the ffmpeg-devel mailing list