Fix SVACE issues
[platform/core/system/edge-orchestration.git] / CMain / src / orchestration_dbus_server.c
index d733400..b5b06d3 100644 (file)
@@ -276,11 +276,15 @@ static void _handle_method_call(
                     token = strtok(ipaddr_list, ",");
                     while (token != NULL)
                     {
-                        ipaddr[num_ip] = (char*) malloc(sizeof(char) * (strlen(token) + 1));
-                        strncpy(ipaddr[num_ip], token, strlen(token));
-                        ipaddr[num_ip][strlen(token)] = '\0';
+                        char *addr = (char*) malloc(sizeof(char) * (strlen(token) + 1));
+                        if (addr)
+                        {
+                            strncpy(addr, token, strlen(token));
+                            addr[strlen(token)] = '\0';
+                            ipaddr[num_ip] = addr;
+                            num_ip++;
+                        }
                         token = strtok(NULL, ",");
-                        num_ip++;
                     }
                 }
                 free(ipaddr_listcopy);
@@ -312,14 +316,6 @@ static void _handle_method_call(
             char *capability = NULL, *message = NULL;
             ret = _read_device_capability(parameters, origin_client_pid, &capability, &message);
 
-               if (capability) {
-                       printf("capability :: %s\n", capability);
-               }
-
-               if (message) {
-                       printf("message :: %s\n", message);
-               }
-
             GVariant *value;
             value = g_variant_new("((ss))", strdup(capability), strdup(message));
 
@@ -335,6 +331,11 @@ static void _handle_method_call(
             char *write_ret = NULL;
             ret = _write_device_capability(parameters, origin_client_pid, &write_ret);
             _gdbus.invocation_return_value(invocation, g_variant_new("(i)", ret));
+            if (write_ret)
+            {
+                free (write_ret);
+                write_ret = NULL;
+            }
         }
 
         if (ret == ORCH_ERROR_NONE)