Skip to content

Commit

Permalink
libstagefright: Check for duration > 0 to avoid DivideByZero crash
Browse files Browse the repository at this point in the history
- duration = 0 can cause divide by zero and for this clip duration
  is indiacted as 0.
- check for duration > 0 rather than duration >= 0

Change-Id: I58ccacbf7ede892dff9626715162ea7b1f2ddbc6
CRs-Fixed: 451855
  • Loading branch information
vivek mehta authored and hyperb1iss committed Feb 19, 2013
1 parent 390e2b1 commit 1bf291a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion media/libstagefright/AwesomePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void AwesomePlayer::notifyListener_l(int msg, int ext1, int ext2) {

bool AwesomePlayer::getBitrate(int64_t *bitrate) {
off64_t size;
if (mDurationUs >= 0 && mCachedSource != NULL
if (mDurationUs > 0 && mCachedSource != NULL
&& mCachedSource->getSize(&size) == OK) {
*bitrate = size * 8000000ll / mDurationUs; // in bits/sec
return true;
Expand Down

0 comments on commit 1bf291a

Please sign in to comment.