Fix for ASAN Issue: alloc-dealloc mismatch 07/187007/2 accepted/tizen_5.0_unified accepted/tizen/5.0/unified/20181102.021914 accepted/tizen/unified/20180820.060056 submit/tizen/20180817.110213 submit/tizen_5.0/20181101.000004
authorsrinivasa.m <srinivasa.m@samsung.com>
Fri, 17 Aug 2018 07:29:17 +0000 (12:59 +0530)
committerSrinivasa Mandadapu <srinivasa.m@samsung.com>
Fri, 17 Aug 2018 07:32:14 +0000 (07:32 +0000)
Change-Id: Ida828cfcc6b741144ee5d27f46c058bd58c3390a

src/shared/message.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 489ebac..e8fd460
@@ -21,6 +21,8 @@
 
 #include <sensor_log.h>
 #include <atomic>
+#include <memory>
+
 
 using namespace ipc;
 
@@ -31,7 +33,7 @@ static std::atomic<uint64_t> sequence(0);
 message::message(size_t capacity)
 : m_size(0)
 , m_capacity(capacity)
-, m_msg((char *)malloc(sizeof(char) * capacity))
+, m_msg(new(std::nothrow) char[sizeof(char) *capacity])
 , ref_cnt(0)
 {
        m_header.id = sequence++;
@@ -61,7 +63,7 @@ message::message(const void *msg, size_t sz)
 message::message(const message &msg)
 : m_size(msg.m_size)
 , m_capacity(msg.m_capacity)
-, m_msg((char *)malloc(sizeof(char) * msg.m_capacity))
+, m_msg(new(std::nothrow) char[(sizeof(char) * msg.m_capacity)])
 , ref_cnt(0)
 {
        ::memcpy(&m_header, &msg.m_header, sizeof(message_header));
@@ -86,7 +88,7 @@ message::message(int error)
 message::~message()
 {
        if (m_msg && ref_cnt == 0) {
-               free(m_msg);
+               delete [] m_msg;
                m_msg = NULL;
        }
 }