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);
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));
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)