On 24.11.2014 05:16, Lukasz Marek wrote:
Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
  libavcodec/options.c | 23 +++++++++++------------
  1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 7f9fb07..8ba997c 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -190,6 +190,11 @@ int avcodec_copy_context(AVCodecContext *dest, const 
AVCodecContext *src)
      }

      av_opt_free(dest);
+    av_freep(&dest->rc_override);
+    av_freep(&dest->intra_matrix);
+    av_freep(&dest->inter_matrix);
+    av_freep(&dest->extradata);
+    av_freep(&dest->subtitle_header);

      memcpy(dest, src, sizeof(*dest));
      av_opt_copy(dest, src);
@@ -205,13 +210,7 @@ int avcodec_copy_context(AVCodecContext *dest, const 
AVCodecContext *src)
      dest->slice_offset    = NULL;
      dest->hwaccel         = NULL;
      dest->internal        = NULL;
-
-    /* reallocate values that should be allocated separately */
-    dest->extradata       = NULL;
-    dest->intra_matrix    = NULL;
-    dest->inter_matrix    = NULL;
-    dest->rc_override     = NULL;
-    dest->subtitle_header = NULL;


This should stay. Updated version attched

>From 722d7e837093212d6e6e6b17814ed408300d25a6 Mon Sep 17 00:00:00 2001
From: Lukasz Marek <lukasz.m.lu...@gmail.com>
Date: Thu, 27 Nov 2014 00:41:16 +0100
Subject: [PATCH] lavc/options: fix leaks in avcodec_copy_context

Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
 libavcodec/options.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 7698434..d637a14 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -190,6 +190,11 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
     }
 
     av_opt_free(dest);
+    av_freep(&dest->rc_override);
+    av_freep(&dest->intra_matrix);
+    av_freep(&dest->inter_matrix);
+    av_freep(&dest->extradata);
+    av_freep(&dest->subtitle_header);
 
     memcpy(dest, src, sizeof(*dest));
     av_opt_copy(dest, src);
@@ -205,6 +210,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
     dest->slice_offset    = NULL;
     dest->hwaccel         = NULL;
     dest->internal        = NULL;
+    dest->coded_frame     = NULL;
 
     /* reallocate values that should be allocated separately */
     dest->extradata       = NULL;
@@ -224,6 +230,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
     }
     alloc_and_copy_or_fail(extradata,    src->extradata_size,
                            FF_INPUT_BUFFER_PADDING_SIZE);
+    dest->extradata_size  = src->extradata_size;
     alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
     alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
     alloc_and_copy_or_fail(rc_override,  src->rc_override_count * sizeof(*src->rc_override), 0);
@@ -238,11 +245,10 @@ fail:
     av_freep(&dest->intra_matrix);
     av_freep(&dest->inter_matrix);
     av_freep(&dest->extradata);
-#if FF_API_MPV_OPT
-    FF_DISABLE_DEPRECATION_WARNINGS
-    av_freep(&dest->rc_eq);
-    FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+    av_freep(&dest->subtitle_header);
+    dest->subtitle_header_size = 0;
+    dest->extradata_size = 0;
+    av_opt_free(dest);
     return AVERROR(ENOMEM);
 }
 
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to