shithub: libvpx

Download patch

ref: acefe86ef81329ecacd6c5a11ffb43c51e82c910
parent: 90cc310e18062c086bd7907ee396a79b00e09194
parent: f651bcb296f6ea15217056487c904689d57a0d0f
author: James Zern <jzern@google.com>
date: Thu Feb 27 09:59:30 EST 2014

Merge "y4m_video_source: fix memory leak"

--- a/test/y4m_video_source.h
+++ b/test/y4m_video_source.h
@@ -35,14 +35,11 @@
 
   virtual ~Y4mVideoSource() {
     vpx_img_free(img_.get());
-    y4m_input_close(&y4m_);
-    if (input_file_)
-      fclose(input_file_);
+    CloseSource();
   }
 
   virtual void Begin() {
-    if (input_file_)
-      fclose(input_file_);
+    CloseSource();
     input_file_ = OpenTestDataFile(file_name_);
     ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: "
         << file_name_;
@@ -89,6 +86,15 @@
   }
 
  protected:
+  void CloseSource() {
+    y4m_input_close(&y4m_);
+    y4m_ = y4m_input();
+    if (input_file_ != NULL) {
+      fclose(input_file_);
+      input_file_ = NULL;
+    }
+  }
+
   std::string file_name_;
   FILE *input_file_;
   testing::internal::scoped_ptr<vpx_image_t> img_;
--