Call avcodec_free_context to release memory if parameters cannot be copied to 
the context.

Signed-off-by: 0xBat <[email protected]>
---
 doc/examples/transcode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 1dc1b50502..2bbe091b94 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -94,9 +94,9 @@ static int open_input_file(const char *filename)
         }
         ret = avcodec_parameters_to_context(codec_ctx, stream->codecpar);
         if (ret < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Failed to copy decoder parameters to 
input decoder context "
-                   "for stream #%u\n", i);
-            return ret;
+        av_log(NULL, AV_LOG_ERROR, "Failed to copy decoder parameters to input 
decoder context for stream #%u\n", i);
+        avcodec_free_context(&codec_ctx);
+        return ret;
         }
 
         /* Inform the decoder about the timebase for the packet timestamps.
-- 
2.52.0.windows.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to