From: kibak.yoon Date: Fri, 24 Nov 2017 10:29:26 +0000 (+0900) Subject: sensord: allocate buf memory for string attribute X-Git-Tag: accepted/tizen/unified/20180403.060147~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee6b37a9754c61e5573437389a0e190ddf026b5d;p=platform%2Fcore%2Fsystem%2Fsensord.git sensord: allocate buf memory for string attribute Change-Id: I7c9c0738a2a574a74aefcf10ab4f49fa180be23d Signed-off-by: kibak.yoon --- diff --git a/src/client/sensor_listener.cpp b/src/client/sensor_listener.cpp index 7c62ea1..b8db2a2 100644 --- a/src/client/sensor_listener.cpp +++ b/src/client/sensor_listener.cpp @@ -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; diff --git a/src/shared/command_types.h b/src/shared/command_types.h index 34cb5fc..d28107d 100644 --- a/src/shared/command_types.h +++ b/src/shared/command_types.h @@ -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 {