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

Commit be9768e8 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Fix memory leaks

Bug: 111407253
Test: manual, libmemunreachable
Change-Id: I69ad7b48498346925dd02c10b206035c0ae49305
parent ff0508b3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -279,6 +279,7 @@ MidiExtractor::~MidiExtractor()
    ALOGV("MidiExtractor dtor");
    AMediaFormat_delete(mFileMetadata);
    AMediaFormat_delete(mTrackMetadata);
    delete mEngine;
}

size_t MidiExtractor::countTracks()
+1 −0
Original line number Diff line number Diff line
@@ -734,6 +734,7 @@ media_status_t MPEG2PSExtractor::Track::read(
    if (inMeta.findData(kKeySEI, &bufType, &bufData, &bufSize)) {
        AMediaFormat_setBuffer(outMeta, AMEDIAFORMAT_KEY_SEI, bufData, bufSize);
    }
    mbuf->release();
    return AMEDIA_OK;
}

+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ media_status_t MPEG2TSSource::read(
    if (inMeta.findData(kKeySEI, &bufType, &bufData, &bufSize)) {
        AMediaFormat_setBuffer(outMeta, AMEDIAFORMAT_KEY_SEI, bufData, bufSize);
    }

    mbuf->release();
    return AMEDIA_OK;
}

+5 −12
Original line number Diff line number Diff line
@@ -50,24 +50,15 @@ MidiIoWrapper::MidiIoWrapper(int fd, off64_t offset, int64_t size) {
    mDataSource = nullptr;
}

MidiIoWrapper::MidiIoWrapper(DataSourceBase *source) {
    ALOGV("MidiIoWrapper(DataSource)");
    mFd = -1;
    mDataSource = source;
    off64_t l;
    if (mDataSource->getSize(&l) == OK) {
        mLength = l;
    } else {
        mLength = 0;
    }
}

class DataSourceUnwrapper : public DataSourceBase {

public:
    explicit DataSourceUnwrapper(CDataSource *csource) {
        mSource = csource;
    }

    virtual ~DataSourceUnwrapper() {}

    virtual status_t initCheck() const { return OK; }

    // Returns the number of bytes read, or -1 on failure. It's not an error if
@@ -98,6 +89,7 @@ private:
MidiIoWrapper::MidiIoWrapper(CDataSource *csource) {
    ALOGV("MidiIoWrapper(CDataSource)");
    mFd = -1;
    mBase = 0;
    mDataSource = new DataSourceUnwrapper(csource);
    off64_t l;
    if (mDataSource->getSize(&l) == OK) {
@@ -112,6 +104,7 @@ MidiIoWrapper::~MidiIoWrapper() {
    if (mFd >= 0) {
        close(mFd);
    }
    delete mDataSource;
}

int MidiIoWrapper::readAt(void *buffer, int offset, int size) {
+2 −2
Original line number Diff line number Diff line
@@ -24,12 +24,12 @@
namespace android {

struct CDataSource;
class DataSourceUnwrapper;

class MidiIoWrapper {
public:
    explicit MidiIoWrapper(const char *path);
    explicit MidiIoWrapper(int fd, off64_t offset, int64_t size);
    explicit MidiIoWrapper(DataSourceBase *source);
    explicit MidiIoWrapper(CDataSource *csource);

    ~MidiIoWrapper();
@@ -43,7 +43,7 @@ private:
    int mFd;
    off64_t mBase;
    int64_t  mLength;
    DataSourceBase *mDataSource;
    DataSourceUnwrapper *mDataSource;
    EAS_FILE mEasFile;
};

Loading