Opened 12 years ago

Closed 12 years ago

#1931 closed defect (fixed)

ogg: ogg_read_header() leaks memory on failure.

Reported by: Dale Curtis Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: ogg leak
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

ogg_read_header() doesn't free memory allocated by ogg_packet() on failure. Ideally it should call ogg_read_close() or free the memory in some other manner.

Leak_DefinitelyLost
197,205 (1,224 direct, 195,981 indirect) bytes in 1 blocks are definitely lost in loss record 3,754 of 3,754

realloc (m_replacemalloc/vg_replace_malloc.c:1088)
av_realloc (/out/Release/../../third_party/ffmpeg/libavutil/mem.c:159)
ogg_new_stream (/out/Release/../../third_party/ffmpeg/libavformat/oggdec.c:216)
ogg_read_page (/out/Release/../../third_party/ffmpeg/libavformat/oggdec.c:321)
ogg_packet (/out/Release/../../third_party/ffmpeg/libavformat/oggdec.c:413)
ogg_read_header (/out/Release/../../third_party/ffmpeg/libavformat/oggdec.c:598)
avformat_open_input (/out/Release/../../third_party/ffmpeg/libavformat/utils.c:641)

Found via valgrind + the attached test case.

Change History (3)

comment:2 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedavformat
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master
$ valgrind --leak-check=full ffmpeg_g -i 116927.ogv
==11205== Memcheck, a memory error detector
==11205== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==11205== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==11205== Command: ffmpeg_g -i 116927.ogv
==11205==
ffmpeg version N-46903-ged27ed9 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 20 2012 01:43:50 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52.  8.100 / 52.  8.100
  libavcodec     54. 73.100 / 54. 73.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.101 /  3. 23.101
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.100 /  0. 17.100
  libpostproc    52.  2.100 / 52.  2.100
[ogg @ 0x66b2c80] Codec not found
[ogg @ 0x66b2c80] Changing stream parameters in multistream ogg is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[ogg @ 0x66b2c80] failed to create or replace stream
116927.ogv: Not yet implemented in FFmpeg, patches welcome
==11205==
==11205== HEAP SUMMARY:
==11205==     in use at exit: 197,205 bytes in 5 blocks
==11205==   total heap usage: 38 allocs, 33 frees, 384,836 bytes allocated
==11205==
==11205== 197,205 (1,224 direct, 195,981 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3
==11205==    at 0x4C2ACCE: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11205==    by 0x54D85F: ogg_read_page (oggdec.c:216)
==11205==    by 0x54DAF4: ogg_packet (oggdec.c:413)
==11205==    by 0x54E9A0: ogg_read_header (oggdec.c:598)
==11205==    by 0x5958EE: avformat_open_input (utils.c:595)
==11205==    by 0x456A6C: opt_input_file (ffmpeg_opt.c:779)
==11205==    by 0x4645EF: parse_option (cmdutils.c:324)
==11205==    by 0x4649C7: parse_options (cmdutils.c:357)
==11205==    by 0x4507CF: main (ffmpeg.c:3140)
==11205==
==11205== LEAK SUMMARY:
==11205==    definitely lost: 1,224 bytes in 1 blocks
==11205==    indirectly lost: 195,981 bytes in 4 blocks
==11205==      possibly lost: 0 bytes in 0 blocks
==11205==    still reachable: 0 bytes in 0 blocks
==11205==         suppressed: 0 bytes in 0 blocks
==11205==
==11205== For counts of detected and suppressed errors, rerun with: -v
==11205== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)

comment:3 by Michael Niedermayer, 12 years ago

Resolution: fixed
Status: openclosed

locally fixed, will be in my next git push

Note: See TracTickets for help on using tickets.