summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorDan Austin <danielaustin@google.com>2015-10-15 13:06:41 -0700
committerSteve Kondik <steve@cyngn.com>2016-03-22 17:14:35 -0700
commit3df4facd824693020ec412cd4afcc8e469e31bb7 (patch)
treebd52a777c65b0f45ad556231960b12f02cefe590 /media
parent37c5d30af6797192de58586ab4ef64b2fcdc7ae9 (diff)
downloadframeworks_av-3df4facd824693020ec412cd4afcc8e469e31bb7.zip
frameworks_av-3df4facd824693020ec412cd4afcc8e469e31bb7.tar.gz
frameworks_av-3df4facd824693020ec412cd4afcc8e469e31bb7.tar.bz2
Fix benign integer overflow conditions for VSYNC add and removal.
There are integer overflow conditions that could occur on vsyncsForLastFrame in VideoFrameScheduler::schedule upon a VSYNC add or removal. Additional checks have been put in place to remove the overflowable conditions. Bug: 24980200 Change-Id: I7dfc25ae1d2f3e3b3382e990adb3c56518c64e8d
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/VideoFrameScheduler.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/media/libstagefright/VideoFrameScheduler.cpp b/media/libstagefright/VideoFrameScheduler.cpp
index 02b8783..c17faf3 100644
--- a/media/libstagefright/VideoFrameScheduler.cpp
+++ b/media/libstagefright/VideoFrameScheduler.cpp
@@ -459,14 +459,16 @@ nsecs_t VideoFrameScheduler::schedule(nsecs_t renderTime) {
mTimeCorrection -= mVsyncPeriod / 2;
renderTime -= mVsyncPeriod / 2;
nextVsyncTime -= mVsyncPeriod;
- --vsyncsForLastFrame;
+ if (vsyncsForLastFrame > 0)
+ --vsyncsForLastFrame;
} else if (mTimeCorrection < -correctionLimit &&
(vsyncsPerFrameAreNearlyConstant || vsyncsForLastFrame == minVsyncsPerFrame)) {
// add a VSYNC
mTimeCorrection += mVsyncPeriod / 2;
renderTime += mVsyncPeriod / 2;
nextVsyncTime += mVsyncPeriod;
- ++vsyncsForLastFrame;
+ if (vsyncsForLastFrame < ULONG_MAX)
+ ++vsyncsForLastFrame;
}
ATRACE_INT("FRAME_VSYNCS", vsyncsForLastFrame);
}