diff options
author | Hyunho Kang <hhstark.kang@samsung.com> | 2016-01-03 17:16:41 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2016-01-03 17:16:41 -0800 |
commit | dada02a2f7f1d4f4d2ea49d588050eb4aa1701f6 (patch) | |
tree | 59e5c1ddaa3cca61f64304702af03abbdeaa014d | |
parent | 4a7badccbddb8764af986d98c0feb1ce908b0276 (diff) | |
parent | 5d88c4a1ed350eb16f55fcce96718a2bb76265fc (diff) | |
download | notification-dada02a2f7f1d4f4d2ea49d588050eb4aa1701f6.tar.gz notification-dada02a2f7f1d4f4d2ea49d588050eb4aa1701f6.tar.bz2 notification-dada02a2f7f1d4f4d2ea49d588050eb4aa1701f6.zip |
Merge "Fix DEREF OF NULL ASSIGN" into tizensubmit/tizen_ivi/20160217.000001submit/tizen_ivi/20160217.000000submit/tizen_common/20160218.142243submit/tizen/20160104.012544accepted/tizen/wearable/20160104.054109accepted/tizen/tv/20160104.054048accepted/tizen/mobile/20160104.054024accepted/tizen/ivi/20160218.022845
-rw-r--r-- | src/notification.c | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/src/notification.c b/src/notification.c index 05bb482..104ed77 100644 --- a/src/notification.c +++ b/src/notification.c @@ -530,6 +530,8 @@ EXPORT_API int notification_get_text(notification_h noti, notification_variable_type_e ret_var_type = 0; int ret_variable_int = 0; double ret_variable_double = 0.0; + int src_len = 0; + int max_len = 0; /* Check noti is valid data */ if (noti == NULL || text == NULL) { @@ -619,8 +621,8 @@ EXPORT_API int notification_get_text(notification_h noti, snprintf(buf_str, sizeof(buf_str), "%d ", ret_variable_int); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; strncat(result_str, buf_str, max_len); @@ -675,8 +677,8 @@ EXPORT_API int notification_get_text(notification_h noti, sizeof(buf_str), "%d", ret_variable_int); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; strncat(result_str, buf_str, max_len); @@ -705,16 +707,13 @@ EXPORT_API int notification_get_text(notification_h noti, translated_str = NULL; } - strncpy(buf_str, translated_str, sizeof(buf_str) - 1); - - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; - - strncat(result_str, buf_str, - max_len); - + if (translated_str != NULL) { + strncpy(buf_str, translated_str, sizeof(buf_str) - 1); + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + strncat(result_str, buf_str, max_len); + } temp_str++; - num_args++; } else if (*(temp_str + 1) == 'f') { /* Get var Value */ @@ -732,14 +731,11 @@ EXPORT_API int notification_get_text(notification_h noti, "%.2f", ret_variable_double); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; - - strncat(result_str, buf_str, - max_len); + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + strncat(result_str, buf_str, max_len); temp_str++; - num_args++; } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') { if (*(temp_str + 3) == 'd') { @@ -781,11 +777,10 @@ EXPORT_API int notification_get_text(notification_h noti, sizeof(buf_str), "%d", ret_variable_int); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; - strncat(result_str, buf_str, - max_len); + strncat(result_str, buf_str, max_len); temp_str += 3; } else if (*(temp_str + 3) == 's') { @@ -800,11 +795,10 @@ EXPORT_API int notification_get_text(notification_h noti, sizeof(buf_str), "%s", ret_val); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; - strncat(result_str, buf_str, - max_len); + strncat(result_str, buf_str, max_len); temp_str += 3; } else if (*(temp_str + 3) == 'f') { @@ -823,11 +817,10 @@ EXPORT_API int notification_get_text(notification_h noti, "%.2f", ret_variable_double); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; - strncat(result_str, buf_str, - max_len); + strncat(result_str, buf_str, max_len); temp_str += 3; } @@ -868,11 +861,10 @@ EXPORT_API int notification_get_text(notification_h noti, sizeof(buf_str), " %d", ret_variable_int); - int src_len = strlen(result_str); - int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; + src_len = strlen(result_str); + max_len = NOTI_TEXT_RESULT_LEN - src_len - 1; - strncat(result_str, buf_str, - max_len); + strncat(result_str, buf_str, max_len); num_args++; } |