OSDN Git Service

Merge "Fix integer overflow and divide-by-zero" into klp-dev am: b264ece2c0 am: bbca2...
authorMarco Nelissen <marcone@google.com>
Mon, 13 Mar 2017 22:43:54 +0000 (22:43 +0000)
committerandroid-build-merger <android-build-merger@google.com>
Mon, 13 Mar 2017 22:43:54 +0000 (22:43 +0000)
am: c2e69851ea

Change-Id: I2720c4439848f9aab8d7fa4f93b548793d129a4f

1  2 
media/libstagefright/AMRExtractor.cpp
media/libstagefright/NuMediaExtractor.cpp

@@@ -189,7 -189,7 +189,7 @@@ sp<MediaSource> AMRExtractor::getTrack(
              mOffsetTable, mOffsetTableLength);
  }
  
 -sp<MetaData> AMRExtractor::getTrackMetaData(size_t index, uint32_t flags) {
 +sp<MetaData> AMRExtractor::getTrackMetaData(size_t index, uint32_t /* flags */) {
      if (mInitCheck != OK || index != 0) {
          return NULL;
      }
@@@ -221,7 -221,7 +221,7 @@@ AMRSource::~AMRSource() 
      }
  }
  
 -status_t AMRSource::start(MetaData *params) {
 +status_t AMRSource::start(MetaData * /* params */) {
      CHECK(!mStarted);
  
      mOffset = mIsWide ? 9 : 6;
@@@ -253,19 -253,19 +253,19 @@@ status_t AMRSource::read
  
      int64_t seekTimeUs;
      ReadOptions::SeekMode mode;
-     if (options && options->getSeekTo(&seekTimeUs, &mode)) {
+     if (mOffsetTableLength > 0 && options && options->getSeekTo(&seekTimeUs, &mode)) {
          size_t size;
          int64_t seekFrame = seekTimeUs / 20000ll;  // 20ms per frame.
          mCurrentTimeUs = seekFrame * 20000ll;
  
 -        int index = seekFrame / 50;
 +        size_t index = seekFrame < 0 ? 0 : seekFrame / 50;
          if (index >= mOffsetTableLength) {
              index = mOffsetTableLength - 1;
          }
  
          mOffset = mOffsetTable[index] + (mIsWide ? 9 : 6);
  
 -        for (int i = 0; i< seekFrame - index * 50; i++) {
 +        for (size_t i = 0; i< seekFrame - index * 50; i++) {
              status_t err;
              if ((err = getFrameSizeByOffset(mDataSource, mOffset,
                              mIsWide, &size)) != OK) {
@@@ -58,9 -58,7 +58,9 @@@ NuMediaExtractor::~NuMediaExtractor() 
  }
  
  status_t NuMediaExtractor::setDataSource(
 -        const char *path, const KeyedVector<String8, String8> *headers) {
 +        const sp<IMediaHTTPService> &httpService,
 +        const char *path,
 +        const KeyedVector<String8, String8> *headers) {
      Mutex::Autolock autoLock(mLock);
  
      if (mImpl != NULL) {
@@@ -68,7 -66,7 +68,7 @@@
      }
  
      sp<DataSource> dataSource =
 -        DataSource::CreateFromURI(path, headers);
 +        DataSource::CreateFromURI(httpService, path, headers);
  
      if (dataSource == NULL) {
          return -ENOENT;
@@@ -389,7 -387,7 +389,7 @@@ ssize_t NuMediaExtractor::fetchTrackSam
                  info->mFinalResult = err;
  
                  if (info->mFinalResult != ERROR_END_OF_STREAM) {
 -                    ALOGW("read on track %d failed with error %d",
 +                    ALOGW("read on track %zu failed with error %d",
                            info->mTrackIndex, err);
                  }
  
@@@ -542,7 -540,7 +542,7 @@@ bool NuMediaExtractor::getTotalBitrate(
      }
  
      off64_t size;
-     if (mDurationUs >= 0 && mDataSource->getSize(&size) == OK) {
+     if (mDurationUs > 0 && mDataSource->getSize(&size) == OK) {
          *bitrate = size * 8000000ll / mDurationUs;  // in bits/sec
          return true;
      }