[FFmpeg-devel] [PATCH 06/11] cbs, cbs_mpeg2, cbs_jpeg: Don't av_freep local variables

Mark Thompson sw at jkqxz.net
Wed May 29 02:09:51 EEST 2019


On 22/05/2019 02:04, Andreas Rheinhardt wrote:
> There is no danger of leaving dangling pointers behind, as the lifespan
> of local variables (including pointers passed (by value) as function
> arguments) ends anyway as soon as we exit their scope.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/cbs.c       | 2 +-
>  libavcodec/cbs_jpeg.c  | 8 ++++----
>  libavcodec/cbs_mpeg2.c | 4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)

I don't agree with the premise of this patch.  I think it's sensible to use av_freep() everywhere, because the marginal cost over av_free() is ~zero and it makes some possible use-after-free errors easier to find.  (While all of these do appear just before the containing functions return, in general it's not useful to even need to think about that.)

- Mark


More information about the ffmpeg-devel mailing list