Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#8230 closed defect (fixed)

avformat_open_input leaks memory

Reported by: Justinas Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: dvvideo leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

AVFormatContext* fmt_ctx = NULL;
avformat_open_input(&fmt_ctx, "/usr/bin/ntpd", NULL, NULL);

In my system an attempt to read /usr/bin/ntpd yields "Operation not permitted", however at this point FFMPEG has already tentatively decided that this is a dv input stream. See below:

ffprobe version n4.2 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 9.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[dv @ 0x556a892d7640] Format dv detected only with low score of 25, misdetection possible!
[dv @ 0x556a892d7640] Can't determine profile of DV input stream.
/usr/bin/ntpd: Operation not permitted

Since file operations are not permitted, avformat_open_input bails out but does not fully free the allocated format context. LeakSanitizer reports a single allocation leak around 32000 bytes.

Attachments (2)

test.cpp (181 bytes ) - added by Justinas 3 years ago.
Leaking program
valgrind_output (1.6 KB ) - added by Justinas 3 years ago.
Unadulterated valgrind output

Download all attachments as: .zip

Change History (6)

comment:1 by Carl Eugen Hoyos, 3 years ago

Version: 4.1.4unspecified

Please test current FFmpeg git head and provide the complete, uncut valgrind output to make this a valid ticket.

by Justinas, 3 years ago

Attachment: test.cpp added

Leaking program

by Justinas, 3 years ago

Attachment: valgrind_output added

Unadulterated valgrind output

comment:2 by Justinas, 3 years ago

Version: unspecifiedgit-master

Built the test program with the current ffmpeg git master, commit id 6023b9fbfef02b71f6acfb1b09e5a12fe9d276e2.

comment:3 by James, 3 years ago

Resolution: fixed
Status: newclosed

comment:4 by Carl Eugen Hoyos, 3 years ago

Keywords: dvvideo leak added
Note: See TracTickets for help on using tickets.