Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Unified Diff: webrtc/modules/video_coding/utility/vp8_header_parser.cc

Issue 1888313002: Fix the issue of undefined-shift in VP8GetBit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove error_ Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/utility/vp8_header_parser.cc
diff --git a/webrtc/modules/video_coding/utility/vp8_header_parser.cc b/webrtc/modules/video_coding/utility/vp8_header_parser.cc
index 631385d0f25095903e676f79dc24e04ea1e1c6cd..ddddfd07aa793d6f5279c5e29c982496272ac93f 100644
--- a/webrtc/modules/video_coding/utility/vp8_header_parser.cc
+++ b/webrtc/modules/video_coding/utility/vp8_header_parser.cc
@@ -35,7 +35,7 @@ static void VP8LoadFinalBytes(VP8BitReader* const br) {
}
}
-static void VP8LoadNewBytes(VP8BitReader* const br) {
+static bool VP8LoadNewBytes(VP8BitReader* const br) {
int BITS = 24;
// Read 'BITS' bits at a time.
if (br->buf_ + sizeof(uint32_t) <= br->buf_end_) {
@@ -55,6 +55,11 @@ static void VP8LoadNewBytes(VP8BitReader* const br) {
} else {
VP8LoadFinalBytes(br);
}
+ if (br->bits_ < 0) {
+ br->eof_ = 1;
pbos-webrtc 2016/04/19 23:11:50 Actually, does this happen from VP8LoadFinalBytes?
jackychen_ 2016/04/20 00:27:18 I'm not sure. So to be safe, I put the check here.
+ return false;
+ }
+ return true;
}
static void VP8InitBitReader(VP8BitReader* const br,
@@ -73,9 +78,9 @@ static void VP8InitBitReader(VP8BitReader* const br,
static int VP8GetBit(VP8BitReader* const br, int prob) {
uint8_t range = br->range_;
if (br->bits_ < 0) {
- VP8LoadNewBytes(br);
+ if (!VP8LoadNewBytes(br))
+ return 0;
}
-
const int pos = br->bits_;
const uint8_t split = (range * prob) >> 8;
const uint8_t value = static_cast<uint8_t>(br->value_ >> pos);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698