• Andreas Rheinhardt's avatar
    avformat/hlsenc: Fix potential segfault upon allocation failure · 149ee954
    Andreas Rheinhardt authored
    The hls muxer allocates an array of VariantStreams, a structure that
    contains pointers to objects that need to be freed on their own. This
    means that the number of allocated VariantStreams needs to be correct
    when they are freed; yet the number of VariantStreams is set in
    update_variant_stream_info() resp. parse_variant_stream_mapstring()
    before the allocation has been checked for success, so that upon error
    an attempt would be made to free the objects whose pointers are
    positioned at position NULL (the location of VariantStreams) +
    offsetof(VariantStream, the corresponding pointer).
    
    Furthermore d1fe1344 added another possibility for the first function
    to leave an inconsistent state behind: If an allocation of one of the
    objects referenced by the VariantStream fails, the VariantStream will be
    freed, but the number of allocated VariantStreams isn't reset, leading
    to the same problem as above. (This was done in the mistaken belief that
    the VariantStreams array would leak otherwise.)
    
    Essentially the same also happens for the number of cc-streams. It has
    been fixed, too.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Reviewed-by: 's avatarSteven Liu <lq@onvideo.cn>
    149ee954
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
configure Loading commit data...