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

Commit 25cb3ca8 authored by Chong Zhang's avatar Chong Zhang
Browse files

Do not crash on missing mime type

bug: 175363115
test: fuzzer with test case in the bug
Change-Id: I42e331db987bcbb76e0927e1d749b72ccfe81f4a
parent 26f3d98f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -60,21 +60,23 @@ void AnotherPacketSource::setFormat(const sp<MetaData> &meta) {

    mIsAudio = false;
    mIsVideo = false;
    const char *mime;

    if (meta == NULL) {
    // Do not use meta if no mime.
    if (meta == NULL || !meta->findCString(kKeyMIMEType, &mime)) {
        return;
    }

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

    if (!strncasecmp("audio/", mime, 6)) {
        mIsAudio = true;
    } else if (!strncasecmp("video/", mime, 6)) {
        mIsVideo = true;
    } else if (!strncasecmp("text/", mime, 5) || !strncasecmp("application/", mime, 12)) {
        return;
    } else {
        CHECK(!strncasecmp("text/", mime, 5) || !strncasecmp("application/", mime, 12));
        ALOGW("Unsupported mime type: %s", mime);
    }
}