[x264-devel] Fix memory leak on encoder close if not all frames are flushed

Anton Mitrofanov git at videolan.org
Sat Feb 19 00:34:08 CET 2011


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Sun Feb 13 12:19:13 2011 -0800| [429af213842178f77ab33bbfc9f6b9cac56c7e7a] | committer: Jason Garrett-Glaser

Fix memory leak on encoder close if not all frames are flushed

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=429af213842178f77ab33bbfc9f6b9cac56c7e7a
---

 encoder/encoder.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 68a6fa1..eb64f57 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -3318,6 +3318,12 @@ void    x264_encoder_close  ( x264_t *h )
 
     h = h->thread[0];
 
+    for( int i = 0; i < h->i_thread_frames; i++ )
+        if( h->thread[i]->b_thread_active )
+            for( int j = 0; j < h->thread[i]->i_ref[0]; j++ )
+                if( h->thread[i]->fref[0][j] && h->thread[i]->fref[0][j]->b_duplicate )
+                    x264_frame_delete( h->thread[i]->fref[0][j] );
+
     for( int i = h->param.i_threads - 1; i >= 0; i-- )
     {
         x264_frame_t **frame;



More information about the x264-devel mailing list