From 1c85fb87ad38e2547426e1c33b309a3c37ab3418 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Fri, 4 Jan 2019 14:48:26 +0900 Subject: [PATCH] Add to init variable and check memory allocation failure Change-Id: I9db4b2da2b706ccf01c6c51492831717b45ff7ac --- src/media_controller_server.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/media_controller_server.c b/src/media_controller_server.c index 412788e..6bdc7e8 100644 --- a/src/media_controller_server.c +++ b/src/media_controller_server.c @@ -62,6 +62,7 @@ static int __mc_server_create(media_controller_server_s **mc_server) _server->playback.state = MC_PLAYBACK_STATE_NONE; _server->playback.position = 0; + _server->playback.playlist_name = NULL; _server->playback.index = NULL; _server->playback.content_type = MC_CONTENT_TYPE_UNDECIDED; @@ -693,6 +694,11 @@ int mc_server_set_playlist_item_index(mc_server_h server, const char *index) mc_server->playback.index = g_strdup(index); + if (mc_server->playback.index == NULL) { + mc_error("Fail to set playlist item index"); + return MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY; + } + return MEDIA_CONTROLLER_ERROR_NONE; } @@ -758,8 +764,10 @@ int mc_server_update_playback_info(mc_server_h server) mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - mc_debug("playback info update: state [%d], position [%llu], playlist_name[%s], index [%s], content_type [%d], age_rating [%d]", - mc_server->playback.state, mc_server->playback.position, mc_server->playback.playlist_name, mc_server->playback.index, mc_server->playback.content_type, mc_server->playback.age_rating); + mc_debug("playback info update: state [%d], position [%llu], content_type [%d], age_rating [%d]", + mc_server->playback.state, mc_server->playback.position, mc_server->playback.content_type, mc_server->playback.age_rating); + if ((mc_server->playback.playlist_name != NULL) && (mc_server->playback.index != NULL)) + mc_debug("playback info update: playlist_name[%s], index [%s]", mc_server->playback.playlist_name, mc_server->playback.index); ret = mc_db_update_playback_info(mc_server->server_name, mc_server->playback); if (ret != MEDIA_CONTROLLER_ERROR_NONE) { -- 2.7.4