[FFmpeg-devel] [PATCH] libavformat/ftp: Do not leak memory in routine ftp_features

Alexander Strasser eclipse7 at gmx.net
Wed Aug 20 06:27:03 CEST 2014


On 2014-08-20 01:25 +0200, Alexander Strasser wrote:
> Should fix CID1231988 (RESOURCE_LEAK)
> 
> Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
> ---
> 
> WARNING: Sorry, I only compile-tested so far.
> 
>   There is one remaining thing, I am not sure of:
> It looks like the variable feet could be uninitialized
> at the point av_freep is called. I think it cannot, but
> I had to follow quite some hops down the call hierarchy.
> 
>  I see two possibilities for taking care of that:
> 
>  1) explicitly initialize it with NULL (could be merged with declaration)
>  2) someone else goes all the way down and if he comes to the same conclusion
>     as I did, we add a comment stating that to ftp_send_command

   After sleeping over it I think I am wrong about 2 because
ftp_send_command may early return and in those cases leave feat
uninitialized.

   So here is some more:

  3) Examine all places ftp_send_command, ftp_status is called
     and do what described for this instance in point 1
  4) Change ftp_send_command and ftp_status to make sure the
     out parameter is always valid or at least NULL after a call

  Doing 4 seem best to me ATM but maybe I missed some things again :(

  Alexander

>  libavformat/ftp.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/ftp.c b/libavformat/ftp.c
> index 9ee9b16..4c071bf 100644
> --- a/libavformat/ftp.c
> +++ b/libavformat/ftp.c
> @@ -450,6 +450,7 @@ static int ftp_features(FTPContext *s)
>          if (av_stristr(feat, "UTF8"))
>              ftp_send_command(s, enable_utf8_command, opts_codes, NULL);
>      }
> +    av_freep(&feat);
>      return 0;
>  }
>  
> -- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140820/e52dcb80/attachment.asc>


More information about the ffmpeg-devel mailing list