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

Unified Diff: media/capture/content/video_capture_oracle.cc

Issue 1263273003: Strict Overflow Prevention video_capture_oracle.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Minor change to match old conditions. Created 5 years, 4 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: media/capture/content/video_capture_oracle.cc
diff --git a/media/capture/content/video_capture_oracle.cc b/media/capture/content/video_capture_oracle.cc
index 3fe9e3608caf746481d9c4dbca85a02a834b0797..6127996fbb70e1c058682794f407bd84c88b9bfd 100644
--- a/media/capture/content/video_capture_oracle.cc
+++ b/media/capture/content/video_capture_oracle.cc
@@ -335,8 +335,11 @@ void VideoCaptureOracle::SetFrameTimestamp(int frame_number,
}
bool VideoCaptureOracle::IsFrameInRecentHistory(int frame_number) const {
- return ((next_frame_number_ - frame_number) < kMaxFrameTimestamps &&
- frame_number <= next_frame_number_ && frame_number >= 0);
+ // Adding (next_frame_number_ >= 0) helps the compiler deduce that there
+ // is no possibility of overflow here.
+ return (frame_number >= 0 && next_frame_number_ >= 0 &&
+ frame_number <= next_frame_number_ &&
+ (next_frame_number_ - frame_number) < kMaxFrameTimestamps);
}
void VideoCaptureOracle::CommitCaptureSizeAndReset(
« 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