diff options
author | Inkyun Kil <inkyun.kil@samsung.com> | 2017-08-08 13:44:46 +0900 |
---|---|---|
committer | Inkyun Kil <inkyun.kil@samsung.com> | 2017-08-08 13:44:46 +0900 |
commit | 5b6af9bc65ee30c85ec25ea4b1da0711b2331f22 (patch) | |
tree | 9adf5b626d5fdaa497f55bd20eff662da44ccaeb | |
parent | 9979dbce3afe29fcc4ef139bbdaade351f3975be (diff) | |
download | data-control-accepted/tizen_3.0_tv.tar.gz data-control-accepted/tizen_3.0_tv.tar.bz2 data-control-accepted/tizen_3.0_tv.zip |
Add null check when allocating memorysubmit/tizen_3.0/20170809.043616accepted/tizen/3.0/wearable/20170810.094404accepted/tizen/3.0/tv/20170810.094443accepted/tizen/3.0/mobile/20170810.094348accepted/tizen/3.0/ivi/20170810.094458accepted/tizen/3.0/common/20170810.115122accepted/tizen_3.0_wearableaccepted/tizen_3.0_tvaccepted/tizen_3.0_mobileaccepted/tizen_3.0_iviaccepted/tizen_3.0_common
Change-Id: Ifab866eb78db789af35748b753e9686b7739e1a0
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rwxr-xr-x | src/data-control-internal.c | 7 | ||||
-rwxr-xr-x | src/data-control-map.c | 5 | ||||
-rwxr-xr-x | src/data-control-noti.c | 5 | ||||
-rwxr-xr-x | src/data-control-provider.c | 12 | ||||
-rwxr-xr-x | src/data-control-sql.c | 9 |
5 files changed, 37 insertions, 1 deletions
diff --git a/src/data-control-internal.c b/src/data-control-internal.c index 9701758..316bd59 100755 --- a/src/data-control-internal.c +++ b/src/data-control-internal.c @@ -624,11 +624,16 @@ char *_get_encoded_path(datacontrol_h provider, char *consumer_appid) encoded_path = g_compute_checksum_for_string(G_CHECKSUM_MD5, path, -1); full_path = (char *)calloc(full_path_len, sizeof(char)); + if (full_path == NULL) { + LOGE("Out of memory"); + goto out; + } snprintf(full_path, full_path_len, "%s%s", DATA_CONTROL_DBUS_PATH_PREFIX, encoded_path); + LOGI("full path : %s ", full_path); +out: free(path); free(encoded_path); - LOGI("full path : %s ", full_path); return full_path; } diff --git a/src/data-control-map.c b/src/data-control-map.c index b5239cf..296d854 100755 --- a/src/data-control-map.c +++ b/src/data-control-map.c @@ -521,6 +521,11 @@ static int __map_request_provider(datacontrol_h provider, datacontrol_request_ty map_response_cb_s *map_dc = *(map_response_cb_s **)map_dc_returned; app_id = map_dc->app_id; datacontrol_consumer_request_info *request_info = (datacontrol_consumer_request_info *)calloc(sizeof(datacontrol_consumer_request_info), 1); + if (request_info == NULL) { + LOGE("Out of memory"); + return DATACONTROL_ERROR_OUT_OF_MEMORY; + } + request_info->request_id = request_id; request_info->type = type; map_dc->request_info_list = g_list_append(map_dc->request_info_list, request_info); diff --git a/src/data-control-noti.c b/src/data-control-noti.c index 53541d9..fc34dae 100755 --- a/src/data-control-noti.c +++ b/src/data-control-noti.c @@ -405,6 +405,11 @@ int datacontrol_add_data_change_cb(datacontrol_h provider, result_cb_info = (add_callback_result_cb_info_s *)calloc(1, sizeof(add_callback_result_cb_info_s)); + if (result_cb_info == NULL) { + LOGE("Out of memory."); + ret = DATACONTROL_ERROR_OUT_OF_MEMORY; + goto err; + } result_cb_info->callback_id = *callback_id; result_cb_info->callback = result_callback; result_cb_info->user_data = result_cb_user_data; diff --git a/src/data-control-provider.c b/src/data-control-provider.c index dda6785..154f208 100755 --- a/src/data-control-provider.c +++ b/src/data-control-provider.c @@ -1013,6 +1013,10 @@ static int __init_changed_noti_consumer_list() consumer_info = (datacontrol_consumer_info *) calloc(1, sizeof(datacontrol_consumer_info)); + if (consumer_info == NULL) { + LOGE("Out of memory"); + continue; + } consumer_info->appid = strdup(app_id); consumer_info->object_path = strdup(object_path); consumer_info->unique_id = strdup(unique_id); @@ -1103,6 +1107,10 @@ static int __set_consumer_app_list( if (!find_list) { consumer_info = (datacontrol_consumer_info *) calloc(1, sizeof(datacontrol_consumer_info)); + if (consumer_info == NULL) { + LOGE("Out of memory"); + return DATACONTROL_ERROR_OUT_OF_MEMORY; + } consumer_info->appid = strdup(caller); consumer_info->object_path = strdup(object_path); consumer_info->unique_id = strdup(unique_id); @@ -2184,6 +2192,10 @@ int datacontrol_provider_add_data_change_consumer_filter_cb( { changed_noti_consumer_filter_info_s *filter_info = (changed_noti_consumer_filter_info_s *)calloc(1, sizeof(changed_noti_consumer_filter_info_s)); + if (filter_info == NULL) { + LOGE("Out of memory"); + return DATACONTROL_ERROR_IO_ERROR; + } *callback_id = _datacontrol_get_data_changed_filter_callback_id(); diff --git a/src/data-control-sql.c b/src/data-control-sql.c index cce6e53..8a5f237 100755 --- a/src/data-control-sql.c +++ b/src/data-control-sql.c @@ -888,6 +888,10 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty app_id = sql_dc->app_id; datacontrol_consumer_request_info *request_info = (datacontrol_consumer_request_info *)calloc(sizeof(datacontrol_consumer_request_info), 1); + if (request_info == NULL) { + LOGE("Out of memory"); + return DATACONTROL_ERROR_OUT_OF_MEMORY; + } request_info->request_id = request_id; request_info->type = type; sql_dc->request_info_list = g_list_append(sql_dc->request_info_list, request_info); @@ -1352,6 +1356,11 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list, total_arg_count = column_count + DATACONTROL_SELECT_EXTRA_COUNT; arg_list = (const char **)malloc(total_arg_count * (sizeof(char *))); + if (arg_list == NULL) { + LOGE("Out of memory"); + bundle_free(b); + return DATACONTROL_ERROR_OUT_OF_MEMORY; + } LOGI("total arg count %d", total_arg_count); |