summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include
diff options
context:
space:
mode:
authorAndrii Kalinich (GitHub) <AKalinich@luxoft.com>2020-01-07 18:24:32 +0200
committerCollin <iCollin@users.noreply.github.com>2020-01-07 11:24:32 -0500
commit9abffa7e47d96d93ffb582d4f7a309757b1a5fe2 (patch)
treef99bc0a018f1fcb59eef4331a1fe89cde843f737 /src/components/application_manager/include
parente137556512215ded94228e33d21ab4c3e1af3017 (diff)
downloadsdl_core-9abffa7e47d96d93ffb582d4f7a309757b1a5fe2.tar.gz
Fix undefined behavior after changing HMICapabilities smart object field (#3116)
* Fix undefined behavior after SO cleanup After cleanup_data() call, delete is used to deallocate memory by pointer, however pointer still hold a value of address of deallocated memory. By that reason SO still have an ability to access that data what might cause UB including core crash in the random places. This function has been updated to set pointers to NULL as well as smart object type to prevent accident access to deallocated memory. * fixup! Fix undefined behavior after SO cleanup * Fix CSmartSchema corruption while copying The issue is that HMICapabilities class is storing different capability fields by raw pointer. In some cases when one thread is trying to copy smart object by pointer, another thread may try to set the same field and destroys a previous one. This may cause a half-copied smart object instance, like smart object with the schema pointing to already destroyed schema item. When such smart object is destroyed, we may see a core crash or unexpected SDL behavior. To avoid such issues, raw pointers were raplced with shared pointers, set by swap() operation. This provide a guarantee that object will not be destroyed while copying by some thread.
Diffstat (limited to 'src/components/application_manager/include')
-rw-r--r--src/components/application_manager/include/application_manager/hmi_capabilities_impl.h46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
index b4610f0375..2c4212c888 100644
--- a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
+++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
@@ -219,7 +219,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported display capabilities
*/
- const smart_objects::SmartObject* display_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr display_capabilities() const OVERRIDE;
/*
* @brief Sets supported display capabilities
@@ -248,7 +248,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported HMI zone capabilities
*/
- const smart_objects::SmartObject* hmi_zone_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr hmi_zone_capabilities() const OVERRIDE;
/*
* @brief Sets supported HMI zone capabilities
@@ -263,7 +263,8 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported SoftButton's capabilities
*/
- const smart_objects::SmartObject* soft_button_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr soft_button_capabilities()
+ const OVERRIDE;
/*
* @brief Sets supported SoftButton's capabilities
@@ -278,7 +279,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported Button's capabilities
*/
- const smart_objects::SmartObject* button_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr button_capabilities() const OVERRIDE;
/*
* @brief Sets supported Button's capabilities
@@ -301,7 +302,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported speech capabilities
*/
- const smart_objects::SmartObject* speech_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr speech_capabilities() const OVERRIDE;
/*
* @brief Sets supported VR capabilities
@@ -316,7 +317,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported VR capabilities
*/
- const smart_objects::SmartObject* vr_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr vr_capabilities() const OVERRIDE;
/*
* @brief Sets supported audio_pass_thru capabilities
@@ -331,7 +332,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported audio_pass_thru capabilities
*/
- const smart_objects::SmartObject* audio_pass_thru_capabilities()
+ const smart_objects::SmartObjectSPtr audio_pass_thru_capabilities()
const OVERRIDE;
/*
@@ -347,14 +348,15 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @return Currently supported pcm_streaming capabilities
*/
- const smart_objects::SmartObject* pcm_stream_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr pcm_stream_capabilities() const OVERRIDE;
/*
* @brief Retrieves information about the preset bank capabilities
*
* @return Currently supported preset bank capabilities
*/
- const smart_objects::SmartObject* preset_bank_capabilities() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr preset_bank_capabilities()
+ const OVERRIDE;
/*
* @brief Sets supported preset bank capabilities
@@ -377,14 +379,14 @@ class HMICapabilitiesImpl : public HMICapabilities {
*
* @param vehicle_type Cuurent vehicle information
*/
- const smart_objects::SmartObject* vehicle_type() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr vehicle_type() const OVERRIDE;
/*
* @brief Retrieves information about the prerecorded speech
*
* @return Currently supported prerecorded speech
*/
- const smart_objects::SmartObject* prerecorded_speech() const OVERRIDE;
+ const smart_objects::SmartObjectSPtr prerecorded_speech() const OVERRIDE;
/*
* @brief Sets supported prerecorded speech
@@ -585,7 +587,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
hmi_apis::Common_Language::eType ui_language_;
hmi_apis::Common_Language::eType vr_language_;
hmi_apis::Common_Language::eType tts_language_;
- smart_objects::SmartObject* vehicle_type_;
+ smart_objects::SmartObjectSPtr vehicle_type_;
smart_objects::SmartObject* ui_supported_languages_;
smart_objects::SmartObject* tts_supported_languages_;
smart_objects::SmartObject* vr_supported_languages_;
@@ -594,17 +596,17 @@ class HMICapabilitiesImpl : public HMICapabilities {
* system_display_capabilities_. For backward compatibility
* display_capabilities_ is not removed.
*/
- smart_objects::SmartObject* display_capabilities_;
+ smart_objects::SmartObjectSPtr display_capabilities_;
smart_objects::SmartObjectSPtr system_display_capabilities_;
- smart_objects::SmartObject* hmi_zone_capabilities_;
- smart_objects::SmartObject* soft_buttons_capabilities_;
- smart_objects::SmartObject* button_capabilities_;
- smart_objects::SmartObject* preset_bank_capabilities_;
- smart_objects::SmartObject* vr_capabilities_;
- smart_objects::SmartObject* speech_capabilities_;
- smart_objects::SmartObject* audio_pass_thru_capabilities_;
- smart_objects::SmartObject* pcm_stream_capabilities_;
- smart_objects::SmartObject* prerecorded_speech_;
+ smart_objects::SmartObjectSPtr hmi_zone_capabilities_;
+ smart_objects::SmartObjectSPtr soft_buttons_capabilities_;
+ smart_objects::SmartObjectSPtr button_capabilities_;
+ smart_objects::SmartObjectSPtr preset_bank_capabilities_;
+ smart_objects::SmartObjectSPtr vr_capabilities_;
+ smart_objects::SmartObjectSPtr speech_capabilities_;
+ smart_objects::SmartObjectSPtr audio_pass_thru_capabilities_;
+ smart_objects::SmartObjectSPtr pcm_stream_capabilities_;
+ smart_objects::SmartObjectSPtr prerecorded_speech_;
bool is_navigation_supported_;
bool is_phone_call_supported_;
bool is_video_streaming_supported_;