summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyong Min <jiyong.min@samsung.com>2017-09-28 13:19:05 +0900
committerJiyong Min <jiyong.min@samsung.com>2017-09-28 13:21:21 +0900
commit1dcb92220500dea0c4d46c8de91fe06d80dd0b6a (patch)
tree7b212c090597848ac263153590e14a0f2fae035d
parentcdb45356679ca4e6e19bad5f9f7b37339c2044f9 (diff)
downloadmedia-controller-1dcb92220500dea0c4d46c8de91fe06d80dd0b6a.tar.gz
media-controller-1dcb92220500dea0c4d46c8de91fe06d80dd0b6a.tar.bz2
media-controller-1dcb92220500dea0c4d46c8de91fe06d80dd0b6a.zip
Modify memory leak of bundle_raw
(fix coverity issue) Change-Id: I12dc14dc114e72ec5c92dbacfbc0e29da23b4dfc Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
-rwxr-xr-xpackaging/capi-media-controller.spec2
-rwxr-xr-xsrc/media_controller_client.c3
-rwxr-xr-xsrc/media_controller_server.c8
-rwxr-xr-xsrc/media_controller_util.c22
4 files changed, 24 insertions, 11 deletions
diff --git a/packaging/capi-media-controller.spec b/packaging/capi-media-controller.spec
index a23d8cf..c14f366 100755
--- a/packaging/capi-media-controller.spec
+++ b/packaging/capi-media-controller.spec
@@ -1,6 +1,6 @@
Name: capi-media-controller
Summary: A media controller library in Tizen Native API
-Version: 0.1.49
+Version: 0.1.50
Release: 1
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/media_controller_client.c b/src/media_controller_client.c
index edbd83e..5ca90f5 100755
--- a/src/media_controller_client.c
+++ b/src/media_controller_client.c
@@ -1022,6 +1022,9 @@ int mc_client_send_custom_command(mc_client_h client, const char *server_name, c
else
message = g_strdup_printf("%s%s%s%s%d%s%s", mc_client->client_name, MC_STRING_DELIMITER, command, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char *)raw_data);
+ if (raw_data != NULL)
+ bundle_free_encoded_rawdata(&raw_data);
+
if (message == NULL) {
mc_error("Error when making message");
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
diff --git a/src/media_controller_server.c b/src/media_controller_server.c
index b857a5c..3b80644 100755
--- a/src/media_controller_server.c
+++ b/src/media_controller_server.c
@@ -518,7 +518,13 @@ int mc_server_send_command_reply(mc_server_h server, const char *client_name, in
}
}
- message = g_strdup_printf("%s%s%d%s%d%s%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char *)raw_data);
+ if ((size_r == 0) || (raw_data == NULL))
+ message = g_strdup_printf("%s%s%d%s%d%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, size_r);
+ else
+ message = g_strdup_printf("%s%s%d%s%d%s%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char *)raw_data);
+
+ if (raw_data)
+ bundle_free_encoded_rawdata(&raw_data);
char *interface_name = mc_util_get_interface_name(MC_CLIENT, client_name);
ret = mc_ipc_send_message(mc_server->dconn, NULL, interface_name, MC_DBUS_SIGNAL_NAME_CMD_REPLY, message, 0);
diff --git a/src/media_controller_util.c b/src/media_controller_util.c
index 7ad6f2a..6c842e6 100755
--- a/src/media_controller_util.c
+++ b/src/media_controller_util.c
@@ -41,15 +41,19 @@ static void _mc_util_check_valid_name(const char *name, char **valid_name)
(old_word[i] == '_' && i != 0)) {
new_word[j++] = old_word[i];
} else {
- new_word[j++] = 'A';
- new_word[j++] = 'P';
- new_word[j++] = 'P';
- new_word[j++] = 'I';
- new_word[j++] = 'D';
- new_word[j++] = '_';
- new_word[j++] = 'S';
- new_word[j++] = 'E';
- new_word[j++] = 'P';
+ if (j + 9 < sizeof(new_word)) {
+ new_word[j++] = 'A';
+ new_word[j++] = 'P';
+ new_word[j++] = 'P';
+ new_word[j++] = 'I';
+ new_word[j++] = 'D';
+ new_word[j++] = '_';
+ new_word[j++] = 'S';
+ new_word[j++] = 'E';
+ new_word[j++] = 'P';
+ } else {
+ mc_error("Error failed to check valid name due to overrun!");
+ }
}
}