You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
FFmpegWriter: Free any old context before clobbering
valgrind caught that AVFORMAT_NEW_STREAM() could be leaking pointers when calling avcodec_alloc_context3(), if there's an existing context already assigned. So we check and free it first, if necessary.
This commit is contained in:
@@ -1067,6 +1067,11 @@ AVStream *FFmpegWriter::add_audio_stream() {
|
||||
if (codec == NULL)
|
||||
throw InvalidCodec("A valid audio codec could not be found for this file.", path);
|
||||
|
||||
// Free any previous memory allocations
|
||||
if (audio_codec_ctx != NULL) {
|
||||
AV_FREE_CONTEXT(audio_codec_ctx);
|
||||
}
|
||||
|
||||
// Create a new audio stream
|
||||
AV_FORMAT_NEW_STREAM(oc, audio_codec_ctx, codec, st)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user