diff options
author | Javier Martinez Canillas <javierm@redhat.com> | 2021-10-01 23:15:25 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-10-13 01:20:10 +0300 |
commit | 0ce723fc8bf6095074562a871b9215d6dea28ab5 (patch) | |
tree | 8db027be3b9ecf3e9f3f9cc2638294c62919c830 /src/android | |
parent | 828f0d97bea247205296a82197bb2795a17ae89b (diff) |
android: Check if Stream configurations were generated correctly
The libcamera Android Camera HAL generates camera configurations for the
StillCapture, Raw and ViewFinder stream roles. But there is only a check
if the configuration generation failed, for the StillCapture stream role.
This could lead to a NULL pointer dereference if a pipeline handler fails
to generate a default configuration for one of the other two stream roles.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/camera_capabilities.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 87a6e1c6..baeedc11 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -408,6 +408,11 @@ CameraCapabilities::initializeYUVResolutions(const PixelFormat &pixelFormat, std::vector<Size> supportedResolutions; std::unique_ptr<CameraConfiguration> cameraConfig = camera_->generateConfiguration({ StreamRole::Viewfinder }); + if (!cameraConfig) { + LOG(HAL, Error) << "Failed to get supported YUV resolutions"; + return supportedResolutions; + } + StreamConfiguration &cfg = cameraConfig->at(0); for (const Size &res : resolutions) { @@ -431,11 +436,17 @@ CameraCapabilities::initializeYUVResolutions(const PixelFormat &pixelFormat, std::vector<Size> CameraCapabilities::initializeRawResolutions(const PixelFormat &pixelFormat) { + std::vector<Size> supportedResolutions; std::unique_ptr<CameraConfiguration> cameraConfig = camera_->generateConfiguration({ StreamRole::Raw }); + if (!cameraConfig) { + LOG(HAL, Error) << "Failed to get supported Raw resolutions"; + return supportedResolutions; + } + StreamConfiguration &cfg = cameraConfig->at(0); const StreamFormats &formats = cfg.formats(); - std::vector<Size> supportedResolutions = formats.sizes(pixelFormat); + supportedResolutions = formats.sizes(pixelFormat); return supportedResolutions; } |