From 14f1aa8c8df4632937c1b2e05be0ba6fc4a7c68d Mon Sep 17 00:00:00 2001 From: "mk5004.lee" Date: Tue, 4 Sep 2018 19:05:59 +0900 Subject: [PATCH] Check result for field data - If the result is Fail, do not execute the condition statement Change-Id: I26a0fb199585ac44c87822bc8187a780fb7dae4f Signed-off-by: mk5004.lee --- src/badge_setting_service.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/badge_setting_service.c b/src/badge_setting_service.c index 587f80e..ee3a382 100755 --- a/src/badge_setting_service.c +++ b/src/badge_setting_service.c @@ -112,7 +112,7 @@ EXPORT_API int badge_db_get_setting_by_appid(const char *appid, badge_setting_h char **query_result = NULL; badge_setting_h result_setting; sqlite3 *db = NULL; - int atd = 0; + int atd; if (appid == NULL) return BADGE_ERROR_INVALID_PARAMETER; @@ -168,14 +168,16 @@ EXPORT_API int badge_db_get_setting_by_appid(const char *appid, badge_setting_h _get_table_field_data_string(query_result, &(result_setting[0].pkgname), 1, col_index++); _get_table_field_data_string(query_result, &(result_setting[0].appid), 1, col_index++); - _get_table_field_data_int(query_result, &atd, col_index++); - - if (atd & BAGDE_APP_DISABLE_BIT) - result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; - else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT) - result_setting[0].allow_to_display = BAGDE_ALLOW_TO_DISPLAY; - else + if (_get_table_field_data_int(query_result, &atd, col_index++)) { + if (atd & BAGDE_APP_DISABLE_BIT) + result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; + else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT) + result_setting[0].allow_to_display = BAGDE_ALLOW_TO_DISPLAY; + else + result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; + } else { result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; + } *setting = result_setting; @@ -254,7 +256,7 @@ EXPORT_API int badge_db_get_allow_to_display_by_appid(char *appid, int *allow_to char *sql_query = NULL; char **query_result = NULL; sqlite3 *db = NULL; - int atd = 0; + int atd; if (appid == NULL) return BADGE_ERROR_INVALID_PARAMETER; @@ -299,14 +301,16 @@ EXPORT_API int badge_db_get_allow_to_display_by_appid(char *appid, int *allow_to col_index = col_count; - _get_table_field_data_int(query_result, &atd, col_index++); - - if (atd & BAGDE_APP_DISABLE_BIT) - *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; - else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT) - *allow_to_display = BAGDE_ALLOW_TO_DISPLAY; - else + if (_get_table_field_data_int(query_result, &atd, col_index++)) { + if (atd & BAGDE_APP_DISABLE_BIT) + *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; + else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT) + *allow_to_display = BAGDE_ALLOW_TO_DISPLAY; + else + *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; + } else { *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY; + } out: if (query_result) -- 2.7.4