shithub: libvpx

Download patch

ref: 66c7dffd5c6b16812d92a125796e3c9642eac886
parent: 1c05e9de2ca852d9e929696f53ab18063f4ef9c0
author: James Zern <jzern@google.com>
date: Tue Jun 25 13:55:28 EDT 2013

tests/*source: test file pointer before reading

if the caller did not abort after an ASSERT failure in Begin()
FillFrame() would segfault.

Change-Id: I2d3f5a0918611bbd081be6f686dea19c56695073

--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -49,7 +49,7 @@
     if (input_file_)
       fclose(input_file_);
     input_file_ = OpenTestDataFile(file_name_);
-    ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
+    ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: "
         << file_name_;
     if (start_) {
       fseek(input_file_, raw_sz_ * start_, SEEK_SET);
@@ -92,6 +92,7 @@
   }
 
   virtual void FillFrame() {
+    ASSERT_TRUE(input_file_ != NULL);
     // Read a frame from input_file.
     if (fread(img_->img_data, raw_sz_, 1, input_file_) == 0) {
       limit_ = frame_;
--- a/test/ivf_video_source.h
+++ b/test/ivf_video_source.h
@@ -52,7 +52,7 @@
 
   virtual void Begin() {
     input_file_ = OpenTestDataFile(file_name_);
-    ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
+    ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: "
         << file_name_;
 
     // Read file header
@@ -72,6 +72,7 @@
   }
 
   void FillFrame() {
+    ASSERT_TRUE(input_file_ != NULL);
     uint8_t frame_hdr[kIvfFrameHdrSize];
     // Check frame header and read a frame from input_file.
     if (fread(frame_hdr, 1, kIvfFrameHdrSize, input_file_)
--- a/test/test_vector_test.cc
+++ b/test/test_vector_test.cc
@@ -149,6 +149,7 @@
 
   virtual void DecompressedFrameHook(const vpx_image_t& img,
                                      const unsigned int frame_number) {
+    ASSERT_TRUE(md5_file_ != NULL);
     char expected_md5[33];
     char junk[128];
 
--- a/test/webm_video_source.h
+++ b/test/webm_video_source.h
@@ -99,7 +99,7 @@
 
   virtual void Begin() {
     input_file_ = OpenTestDataFile(file_name_);
-    ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
+    ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: "
         << file_name_;
 
     nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb,
@@ -130,6 +130,7 @@
   }
 
   void FillFrame() {
+    ASSERT_TRUE(input_file_ != NULL);
     if (chunk_ >= chunks_) {
       unsigned int track;