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

Commit 14c10ebb authored by Gopalakrishnan Nallasamy's avatar Gopalakrishnan Nallasamy
Browse files

StagefrighRecorder:check mWriter before using fd

ftruncate(fd) would be useless if mWriter was NULL already.
Hence moved mWriter nullptr check before ftruncate(fd).

Bug: 128366317

Test: atest CtsMediaTestCases:android.media.cts.MediaRecorderTest

Change-Id: I46b8c4718bc8a90712b7ec0b54d8239106106018
parent baf2d2c6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -400,12 +400,14 @@ status_t StagefrightRecorder::setNextOutputFile(int fd) {
        return -EBADF;
    }

    // start with a clean, empty file
    ftruncate(fd, 0);
    if (mWriter == NULL) {
    if (mWriter == nullptr) {
        ALOGE("setNextOutputFile failed. Writer has been freed");
        return INVALID_OPERATION;
    }

    // start with a clean, empty file
    ftruncate(fd, 0);

    return mWriter->setNextFd(fd);
}