]> granicus.if.org Git - libvpx/commitdiff
Fix bug in error handling that causes segfault
authorJim Bankoski <jimbankoski@google.com>
Thu, 19 Jun 2014 19:10:05 +0000 (12:10 -0700)
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>
Fri, 20 Jun 2014 21:44:50 +0000 (14:44 -0700)
See: https://code.google.com/p/chromium/issues/detail?id=362697

The code properly catches an invalid stream but seg faults instead of
returning an error due to a buffer not having been initialized. This
code fixes that.

Change-Id: I695595e742cb08807e1dfb2f00bc097b3eae3a9b

test/invalid_file_test.cc
vp9/decoder/vp9_decodeframe.c
vp9/decoder/vp9_decoder.c

index 4c0467568c6daa51a0e204844b1b8886feb50aaa..e7f2a48daf9f3e5d95623c920fb5166d86f373ef 100644 (file)
@@ -64,7 +64,7 @@ class InvalidFileTest
   FILE *res_file_;
 };
 
-TEST_P(InvalidFileTest, DISABLED_ReturnCode) {
+TEST_P(InvalidFileTest, ReturnCode) {
   const std::string filename = GET_PARAM(1);
   libvpx_test::CompressedVideoSource *video = NULL;
 
index fc70035f2aaaf3440b90d997e2e47d8e87166e99..f36105fcf4879d333df80d917542ac49ac100046 100644 (file)
@@ -1077,7 +1077,7 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
     // Show an existing frame directly.
     const int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)];
 
-    if (cm->frame_bufs[frame_to_show].ref_count < 1)
+    if (frame_to_show < 0 || cm->frame_bufs[frame_to_show].ref_count < 1)
       vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
                          "Buffer %d does not contain a decoded frame",
                          frame_to_show);
index 5859859fae68b07a7f6bcf55d60580624637f8c6..f610262fab44e26a9ffd3ae7c7190da1fccfde34 100644 (file)
@@ -260,10 +260,10 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
     // TODO(jkoleszar): Error concealment is undefined and non-normative
     // at this point, but if it becomes so, [0] may not always be the correct
     // thing to do here.
-    if (cm->frame_refs[0].idx != INT_MAX)
+    if (cm->frame_refs[0].idx != INT_MAX && cm->frame_refs[0].buf != NULL)
       cm->frame_refs[0].buf->corrupted = 1;
 
-    if (cm->frame_bufs[cm->new_fb_idx].ref_count > 0)
+    if (cm->new_fb_idx > 0 && cm->frame_bufs[cm->new_fb_idx].ref_count > 0)
       cm->frame_bufs[cm->new_fb_idx].ref_count--;
 
     return -1;