[libcamera-devel,v2,1/2] libcamera: pipeline: simple: Check converter_
diff mbox series

Message ID 20230227224910.151337-2-suhrid.subramaniam@mediatek.com
State Superseded
Headers show
Series
  • Check converter_ validity
Related show

Commit Message

Suhrid Subramaniam Feb. 27, 2023, 10:49 p.m. UTC
- If no converter is found, converter_ becomes a nullptr and
!converter_->isValid() causes a segmentation fault.
- Avoid this by checking if converter_ is a nullptr.

Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
---
 src/libcamera/pipeline/simple/simple.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Elder Feb. 28, 2023, 6:50 a.m. UTC | #1
On Mon, Feb 27, 2023 at 02:49:09PM -0800, Suhrid Subramaniam via libcamera-devel wrote:
> - If no converter is found, converter_ becomes a nullptr and
> !converter_->isValid() causes a segmentation fault.
> - Avoid this by checking if converter_ is a nullptr.
> 
> Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
> ---
>  src/libcamera/pipeline/simple/simple.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index 24ded4db..2423ec10 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -493,7 +493,7 @@ int SimpleCameraData::init()
>  	MediaDevice *converter = pipe->converter();
>  	if (converter) {
>  		converter_ = ConverterFactoryBase::create(converter);
> -		if (!converter_->isValid()) {
> +		if (!converter_) {

We still need to check that the converter is valid if it exists.


Paul

>  			LOG(SimplePipeline, Warning)
>  				<< "Failed to create converter, disabling format conversion";
>  			converter_.reset();
> -- 
> 2.39.0
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 24ded4db..2423ec10 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -493,7 +493,7 @@  int SimpleCameraData::init()
 	MediaDevice *converter = pipe->converter();
 	if (converter) {
 		converter_ = ConverterFactoryBase::create(converter);
-		if (!converter_->isValid()) {
+		if (!converter_) {
 			LOG(SimplePipeline, Warning)
 				<< "Failed to create converter, disabling format conversion";
 			converter_.reset();