From b80ca66300d18def8ef85ab66b084e6a19f45f52 Mon Sep 17 00:00:00 2001 From: Hyunjee Kim Date: Wed, 13 May 2020 14:49:26 +0900 Subject: [PATCH] Add exceptions for ucnv Change-Id: Ibccb65be6b942081f85f2cbccd33a13223fc3858 Signed-off-by: Hyunjee Kim --- src/utils_i18n_ucnv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils_i18n_ucnv.c b/src/utils_i18n_ucnv.c index 533ad86..78ec66e 100644 --- a/src/utils_i18n_ucnv.c +++ b/src/utils_i18n_ucnv.c @@ -21,6 +21,12 @@ int i18n_ucnv_get_max_bytes_for_string(int32_t length, int32_t max_char_size) { + if(length < 0 || max_char_size < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); return ((int32_t)(length)+10)*(int32_t)(max_char_size); } -- 2.7.4