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

Commit 5adc76c4 authored by Tom Keel's avatar Tom Keel Committed by Eino-Ville Talvala
Browse files

DO NOT MERGE: libcameraservice: Fix nullptr crash when no client.



This change prevents a crash in the camera service when the camera
HAL notifies the service about the absence of a removable camera and
there happens to be no client connected to the service. It checks
that the pointer returned from clientToDisconnect.get() is non-null
before trying to dereference it (as is done in existing code
immediately below this change).

Bug: 25165323
Change-Id: I8055654bac980542e63ea7f52bf897eaafbc09bc
Signed-off-by: default avatarTom Keel <thomas.keel@intel.com>
parent e710ae53
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -315,9 +315,11 @@ void CameraService::onDeviceStatusChanged(camera_device_status_t cameraId,
            clientToDisconnect = removeClientLocked(id);

            // Notify the client of disconnection
            if (clientToDisconnect != nullptr) {
                clientToDisconnect->notifyError(ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED,
                        CaptureResultExtras{});
            }
        }

        ALOGI("%s: Client for camera ID %s evicted due to device status change from HAL",
                __FUNCTION__, id.string());