From 51a7da9ce54572f4291ec9101238cf1df3d6697e Mon Sep 17 00:00:00 2001 From: Tom Keel Date: Thu, 8 Oct 2015 16:42:56 +0200 Subject: 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). Change-Id: I8055654bac980542e63ea7f52bf897eaafbc09bc Signed-off-by: Tom Keel --- services/camera/libcameraservice/CameraService.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index db6272b..861e519 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -314,8 +314,10 @@ void CameraService::onDeviceStatusChanged(camera_device_status_t cameraId, clientToDisconnect = removeClientLocked(id); // Notify the client of disconnection - clientToDisconnect->notifyError(ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED, - CaptureResultExtras{}); + 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", -- cgit v1.1