Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32bdfd5a authored by Andreas Huber's avatar Andreas Huber
Browse files

Fix a reference to a stale pointer in AwesomePlayer.

The pointer returned by MetaData::findCString may become stale if the metadata
object is modified. Make a copy of the returned mime type in order to prevent
MediaPlayer::dump log corruption.

Change-Id: I9077aee36c4316d83b37fb909bf91e6b3f75d5d2
parent 1d2acaff
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -385,10 +385,12 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
    for (size_t i = 0; i < extractor->countTracks(); ++i) {
        sp<MetaData> meta = extractor->getTrackMetaData(i);

        const char *mime;
        CHECK(meta->findCString(kKeyMIMEType, &mime));
        const char *_mime;
        CHECK(meta->findCString(kKeyMIMEType, &_mime));

        String8 mime = String8(_mime);

        if (!haveVideo && !strncasecmp(mime, "video/", 6)) {
        if (!haveVideo && !strncasecmp(mime.string(), "video/", 6)) {
            setVideoSource(extractor->getTrack(i));
            haveVideo = true;

@@ -409,9 +411,9 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
                mStats.mTracks.push();
                TrackStat *stat =
                    &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex);
                stat->mMIME = mime;
                stat->mMIME = mime.string();
            }
        } else if (!haveAudio && !strncasecmp(mime, "audio/", 6)) {
        } else if (!haveAudio && !strncasecmp(mime.string(), "audio/", 6)) {
            setAudioSource(extractor->getTrack(i));
            haveAudio = true;

@@ -421,10 +423,10 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
                mStats.mTracks.push();
                TrackStat *stat =
                    &mStats.mTracks.editItemAt(mStats.mAudioTrackIndex);
                stat->mMIME = mime;
                stat->mMIME = mime.string();
            }

            if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS)) {
            if (!strcasecmp(mime.string(), MEDIA_MIMETYPE_AUDIO_VORBIS)) {
                // Only do this for vorbis audio, none of the other audio
                // formats even support this ringtone specific hack and
                // retrieving the metadata on some extractors may turn out
@@ -436,7 +438,7 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
                    modifyFlags(AUTO_LOOPING, SET);
                }
            }
        } else if (!strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP)) {
        } else if (!strcasecmp(mime.string(), MEDIA_MIMETYPE_TEXT_3GPP)) {
            addTextSource(extractor->getTrack(i));
        }
    }