From bd3e2e03f3ab686c52982a9e50cae853128172cf Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Mon, 17 Mar 2014 13:01:41 -0700 Subject: camera2: Fix segfault when using null availability listener ICameraService::addListener / removeListener will now return BAD_VALUE if a null listener is used. Bug: 12891434 Change-Id: I9764110094d8fd42e22fcc8df3ef0e73c1b070e7 --- services/camera/libcameraservice/CameraService.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'services/camera/libcameraservice/CameraService.cpp') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index eeedfc9..5957d97 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -655,6 +655,11 @@ status_t CameraService::addListener( const sp& listener) { ALOGV("%s: Add listener %p", __FUNCTION__, listener.get()); + if (listener == 0) { + ALOGE("%s: Listener must not be null", __FUNCTION__); + return BAD_VALUE; + } + Mutex::Autolock lock(mServiceLock); Vector >::iterator it, end; @@ -683,6 +688,11 @@ status_t CameraService::removeListener( const sp& listener) { ALOGV("%s: Remove listener %p", __FUNCTION__, listener.get()); + if (listener == 0) { + ALOGE("%s: Listener must not be null", __FUNCTION__); + return BAD_VALUE; + } + Mutex::Autolock lock(mServiceLock); Vector >::iterator it; -- cgit v1.1