Fix heap use after free issue 17/317517/1
authorChanggyu Choi <changyu.choi@samsung.com>
Fri, 3 Jan 2025 04:30:18 +0000 (13:30 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Fri, 3 Jan 2025 04:30:18 +0000 (13:30 +0900)
To resolve UAF issue, source object must be maintained until end of the UnrefSelf().

Change-Id: If8017e0bb220f4f63f4cd771f46ebf8110c8fcdc
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/tizen-core/stub.cc

index 9bf2ce16a50e98074c698474b1d5d114871d9cdc..2f0aeb7273ec65e613d4e668e8d1d7128b35990a 100644 (file)
@@ -466,7 +466,7 @@ API int tizen_core_source_destroy(tizen_core_source_h source) {
     return TIZEN_CORE_ERROR_INVALID_PARAMETER;
   }
 
-  auto* handle = static_cast<SourceExt*>(source);
+  auto handle = static_cast<SourceExt*>(source)->shared_from_this();
   handle->UnrefSelf();
   return TIZEN_CORE_ERROR_NONE;
 }