Rectifyng this poniter deletion from member function 07/200307/1
authorAvichal <avichal.a@samsung.com>
Thu, 21 Feb 2019 09:49:22 +0000 (15:19 +0530)
committerAvichal <avichal.a@samsung.com>
Thu, 21 Feb 2019 09:49:22 +0000 (15:19 +0530)
ASAN TFD289

Change-Id: I8261058c690244e6a21df616c67dae5dda1117ff

src/server/sensor_handler.cpp
src/shared/channel.cpp
src/shared/message.cpp

index fcfef69..b9cdfca 100644 (file)
@@ -83,8 +83,10 @@ int sensor_handler::notify(const char *uri, sensor_data_t *data, int len)
        for (auto it = m_observers.begin(); it != m_observers.end(); ++it)
                (*it)->update(uri, msg);
 
-       if (msg->ref_count() == 0)
-               msg->unref();
+       if (msg->ref_count() == 0) {
+               delete msg;
+               msg = NULL;
+       }
 
        set_cache(data, len);
 
index 446c881..639e9c1 100644 (file)
@@ -49,8 +49,13 @@ public:
                if (!m_ch->send_sync(m_msg))
                        return false;
 
-               if (m_msg)
+               if (m_msg) {
                        m_msg->unref();
+                       if(m_msg->ref_count() <= 0) {
+                               delete m_msg;
+                               m_msg = NULL;
+                       }
+               }
 
                return false;
        }
index 799e64f..f53dd5e 100755 (executable)
@@ -87,7 +87,7 @@ message::message(int error)
 
 message::~message()
 {
-       if (m_msg && ref_cnt == 0) {
+       if (m_msg) {
                delete [] m_msg;
                m_msg = NULL;
        }
@@ -146,12 +146,12 @@ void message::unref(void)
 {
        ref_cnt--;
 
-       if (ref_cnt > 0 || !m_msg)
+       /*if (ref_cnt > 0 || !m_msg)
                return;
 
        delete [] m_msg;
        m_msg = NULL;
-       delete this;
+       delete this;*/
 }
 
 int message::ref_count(void)