From 444811c0105673bd04c46afce40484898b661a2f Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 11 Jan 2017 02:28:03 -0800 Subject: [PATCH] Don't overflow when dealing with large segment numbers Issue: #2311 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144182445 --- .../android/exoplayer2/source/dash/manifest/SegmentBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java index ef319d508d7..70a65e932af 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java @@ -143,7 +143,7 @@ public int getSegmentNum(long timeUs, long periodDurationUs) { } else { // The high index cannot be unbounded. Identify the segment using binary search. while (lowIndex <= highIndex) { - int midIndex = (lowIndex + highIndex) / 2; + int midIndex = lowIndex + (highIndex - lowIndex) / 2; long midTimeUs = getSegmentTimeUs(midIndex); if (midTimeUs < timeUs) { lowIndex = midIndex + 1;