Fix heap use after free issue 06/317606/1
authorChanggyu Choi <changyu.choi@samsung.com>
Fri, 3 Jan 2025 04:30:18 +0000 (13:30 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Mon, 6 Jan 2025 00:55:40 +0000 (09:55 +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 282776b4a9b7fcdac1985f4fcd549642c0aadeb1..014721151eb6afd254544a0876841bc7d0714ba9 100644 (file)
@@ -468,7 +468,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;
 }