sensord: allocate buf memory for string attribute 18/161618/4
authorkibak.yoon <kibak.yoon@samsung.com>
Fri, 24 Nov 2017 10:29:26 +0000 (19:29 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Mon, 4 Dec 2017 07:40:48 +0000 (16:40 +0900)
Change-Id: I7c9c0738a2a574a74aefcf10ab4f49fa180be23d
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/client/sensor_listener.cpp
src/shared/command_types.h

index 7c62ea1..b8db2a2 100644 (file)
@@ -392,6 +392,10 @@ int sensor_listener::set_attribute(int attribute, const char *value, int len)
        msg.set_type(CMD_LISTENER_ATTR_STR);
        buf.listener_id = m_id;
        buf.attribute = attribute;
+
+       buf.value = new(std::nothrow) char[len];
+       retvm_if(!buf.value, -ENOMEM, "Failed to allocate memory");
+
        memcpy(buf.value, value, len);
        buf.len = len;
 
index 34cb5fc..d28107d 100644 (file)
@@ -88,7 +88,7 @@ typedef struct  {
        int listener_id;
        int attribute;
        int len;
-       char value[0];
+       char *value;
 } cmd_listener_attr_str_t;
 
 typedef struct {