location: add null terminator 24/104324/3
authorMunkyu Im <munkyu.im@samsung.com>
Tue, 13 Dec 2016 06:02:49 +0000 (15:02 +0900)
committerMunkyu Im <munkyu.im@samsung.com>
Tue, 13 Dec 2016 09:24:25 +0000 (18:24 +0900)
To parse string properly,
need to add null terminator after the last character.

Change-Id: I12541857a1018fe0cc2892c4e271de0723aca23c
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
src/msgproc_location.cpp

index cbc1c3d84cb2b7122a69f2a0dd023b637f92893a..06b1cfd9291d6a067f0f1ebf1b93054e43dde339 100644 (file)
@@ -264,7 +264,18 @@ bool msgproc_location(ijcommand* ijcmd)
     }
     else
     {
-        setting_location(ijcmd->data);
+        unsigned short length = ijcmd->msg.length;
+        char *data = (char *)malloc(length + 1);
+        if (!data) {
+            LOGERR("failed to malloc\n");
+            return false;
+        }
+        memcpy(data, ijcmd->data, length);
+        data[length] = '\0';
+
+        setting_location(data);
+
+        free(data);
     }
     return true;
 }