(NativeImageSource) Return nullptr if NativeImageSource::New() failed 43/319743/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 17 Feb 2025 07:06:27 +0000 (16:06 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Thu, 20 Feb 2025 02:47:23 +0000 (02:47 +0000)
For vulkan backend case, NativeImageSource's mImpl return nullptr.

But NativeImageSource object itself is not empty, we can call
NativeImageSource API freely, and got crash.

To avoid these kind of issue, let we return nullptr if NativeImageSource
creation failed. (Similar with NativeImageSourceQueue)

Change-Id: I5113a01bf8183a35a3bcfebcca5b4673db753e49
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/public-api/adaptor-framework/native-image-source.cpp

index 089f2534f5bb02ed2c4d1934aeb52a10003e1976..ff613e43b3ab7ace7b997684e03568063ead601d 100644 (file)
@@ -31,18 +31,26 @@ NativeImageSourcePtr NativeImageSource::New(uint32_t width, uint32_t height, Col
 {
   Any                  empty;
   NativeImageSourcePtr image = new NativeImageSource(width, height, depth, empty);
-  return image;
+  if(image->mImpl)
+  {
+    return image;
+  }
+  return nullptr;
 }
 
-Any NativeImageSource::GetNativeImageSource()
+NativeImageSourcePtr NativeImageSource::New(Any nativeImageSource)
 {
-  return mImpl->GetNativeImageSource();
+  NativeImageSourcePtr image = new NativeImageSource(0, 0, COLOR_DEPTH_DEFAULT, nativeImageSource);
+  if(image->mImpl)
+  {
+    return image;
+  }
+  return nullptr;
 }
 
-NativeImageSourcePtr NativeImageSource::New(Any nativeImageSource)
+Any NativeImageSource::GetNativeImageSource()
 {
-  NativeImageSourcePtr image = new NativeImageSource(0, 0, COLOR_DEPTH_DEFAULT, nativeImageSource);
-  return image;
+  return mImpl->GetNativeImageSource();
 }
 
 bool NativeImageSource::GetPixels(std::vector<uint8_t>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const