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

Commit a84d6e77 authored by Ashish Kumar Gupta's avatar Ashish Kumar Gupta
Browse files

Add safe check for mtp_data_header

header is initialized using mIobuf[0].bufs.data(). If mIobuf[0].bufs is NULL, dereferencing header could produce NPE.

Bug: 244106060
Change-Id: I8ca9c4a8c433bb1935879148d918ba6e120d5aa9
Test: presubmit
parent c2f42a7e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -591,6 +591,9 @@ int MtpFfsHandle::sendFile(mtp_file_range mfr) {

    // Send the header data
    mtp_data_header *header = reinterpret_cast<mtp_data_header*>(mIobuf[0].bufs.data());
    if (header == NULL) {
        return -1;
    }
    header->length = htole32(given_length);
    header->type = htole16(2); // data packet
    header->command = htole16(mfr.command);