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

Commit 011f25fb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent null vector accessing in USB HAL"

parents 9e1b8792 bdf4ac78
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -97,6 +97,11 @@ int32_t writeFile(const std::string &filename, const std::string &contents) {
Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2) {
    std::string enabled, status;

    if (currentPortStatus_1_2 == NULL || currentPortStatus_1_2->size() == 0) {
        ALOGE("currentPortStatus_1_2 is not available");
        return Status::ERROR;
    }

    (*currentPortStatus_1_2)[0].supportedContaminantProtectionModes = 0;
    (*currentPortStatus_1_2)[0].supportedContaminantProtectionModes |=
        ContaminantProtectionMode::FORCE_SINK;
@@ -563,6 +568,7 @@ void queryVersionHelper(android::hardware::usb::V1_2::implementation::Usb *usb,
    if (usb->mCallback_1_0 != NULL) {
        if (callback_V1_2 != NULL) {
            status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_2);
            if (status == Status::SUCCESS)
                queryMoistureDetectionStatus(currentPortStatus_1_2);
        } else if (callback_V1_1 != NULL) {
            status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_1);