• Andreas Rheinhardt's avatar
    avformat/wavenc: Fix leak and segfault on reallocation error · 19ae8732
    Andreas Rheinhardt authored
    Up until now, the wav muxer used a reallocation of the form ptr =
    av_realloc(ptr, size); that leaks upon error. Furthermore, if a
    failed reallocation happened when writing the trailer, a segfault
    would occur due to avio_write(NULL, size) because the muxer only
    prints an error message upon allocation error, but does not return
    the error.
    
    Moreover setting the pointer to the buffer to NULL on error seems to
    be done on purpose in order to record that an error has occured so that
    outputting the peak values is no longer attempted. This behaviour has
    been retained by simply disabling whether peak data should be written
    if an error occurs.
    
    Finally, the reallocation is now done once per peak block and not once
    per peak block per channel; it is also done with av_fast_realloc and not
    with a linear size increase.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    19ae8732
wavenc.c 20.6 KB