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

Commit cb0c1386 authored by Marco Nelissen's avatar Marco Nelissen Committed by Dan Pasanen
Browse files

Fix issues with extractor dumpsys

Tracks and descriptions were added to their respective lists in
opposite order, so dumpsys could mix up the format and active
state for a given track. Also fix potential NULL pointer dereference.

Bug: 33179012
Bug: 23270724
Change-Id: I700d535da0e72f5641bf9257a34fdb5d5d068b12
(cherry picked from commit 50a6f88b)
parent bc1e3691
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -209,13 +209,18 @@ String8 ExtractorInstance::toString() const {
    for (size_t i = 0; i < tracks.size(); i++) {
        const String8 desc = trackDescriptions.itemAt(i);
        str.appendFormat("    track {%s} ", desc.string());
        const sp<IMediaSource> source = tracks.itemAt(i).promote();
        wp<IMediaSource> wSource = tracks.itemAt(i);
        if (wSource == NULL) {
            str.append(": null\n");
        } else {
            const sp<IMediaSource> source = wSource.promote();
            if (source == NULL) {
                str.append(": deleted\n");
            } else {
                str.appendFormat(": active\n");
            }
        }
    }
    return str;
}

@@ -232,9 +237,14 @@ void registerMediaSource(
        if (extractor != NULL && extractor == ex) {
            if (instance.tracks.size() > 5) {
                instance.tracks.resize(5);
                instance.trackDescriptions.resize(5);
            }
            instance.tracks.push_front(source);
            instance.trackDescriptions.add(source->getFormat()->toString());
            if (source != NULL) {
                instance.trackDescriptions.push_front(source->getFormat()->toString());
            } else {
                instance.trackDescriptions.push_front(String8::empty());
            }
            break;
        }
    }