]> granicus.if.org Git - libvpx/commitdiff
tests/*source: test file pointer before reading
authorJames Zern <jzern@google.com>
Wed, 26 Jun 2013 00:55:28 +0000 (17:55 -0700)
committerJames Zern <jzern@google.com>
Wed, 26 Jun 2013 00:57:52 +0000 (17:57 -0700)
if the caller did not abort after an ASSERT failure in Begin()
FillFrame() would segfault.

Change-Id: I2d3f5a0918611bbd081be6f686dea19c56695073

test/i420_video_source.h
test/ivf_video_source.h
test/test_vector_test.cc
test/webm_video_source.h

index 0dc29319c65c3f6d0d59c0dd7c163436240054b2..bcbe8a71752d0bafef33bc9e6a01ed4dd21f0204 100644 (file)
@@ -49,7 +49,7 @@ class I420VideoSource : public VideoSource {
     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 @@ class I420VideoSource : public VideoSource {
   }
 
   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_;
index 48c3a7dcd8f21e187f6c486ece38e215d56c5988..88bc597ae93fc3807ae4817c6bca062e058bfaec 100644 (file)
@@ -52,7 +52,7 @@ class IVFVideoSource : public CompressedVideoSource {
 
   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 @@ class IVFVideoSource : public CompressedVideoSource {
   }
 
   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_)
index 481860e4436b779a38d633fab4410bc5fc7952f4..fe9c402f5d2c361d9e04e7206a1b4e161eb513eb 100644 (file)
@@ -149,6 +149,7 @@ class TestVectorTest : public ::libvpx_test::DecoderTest,
 
   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];
 
index c7919a9795410bae3c5193b871caa5e94269448c..9fc8545935f6f3b11ccf6edc648d04fd56468acc 100644 (file)
@@ -99,7 +99,7 @@ class WebMVideoSource : public CompressedVideoSource {
 
   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 @@ class WebMVideoSource : public CompressedVideoSource {
   }
 
   void FillFrame() {
+    ASSERT_TRUE(input_file_ != NULL);
     if (chunk_ >= chunks_) {
       unsigned int track;