Fix svace error 80/138080/1
authorHyunjee Kim <hj0426.kim@samsung.com>
Tue, 11 Jul 2017 03:13:13 +0000 (12:13 +0900)
committerHyunjee Kim <hj0426.kim@samsung.com>
Tue, 11 Jul 2017 04:43:24 +0000 (13:43 +0900)
Change-Id: I8e3a468f2842f89f37a3bf162fe48908293d705d
Signed-off-by: Hyunjee Kim <hj0426.kim@samsung.com>
src/include/utils_i18n_private.h
src/utils_i18n_ubidi.c

index 692c2dd10952a3e36103d8f5afeed77ab7cf028a..108606f8dba180123226a84ffb8430e5807cf40d 100644 (file)
@@ -85,6 +85,10 @@ extern "C" {
 
 #define ERR_MAPPING(ICU_ERROR, BASE_UTILS_ERROR) BASE_UTILS_ERROR = \
                                                                                                                                        (i18n_error_code_e)_i18n_error_mapping((int)ICU_ERROR)
+#define COPY_STR(dst, src, dst_len) do {            \
+                       strncpy((dst), (src), (dst_len));       \
+                       (dst)[(dst_len) - 1] = '\0';            \
+} while (0)
 
 int _i18n_error_mapping(int err);
 int _i18n_error_mapping_reverse(int err);
index 03449b74ae59fe4063babe9411c431a35fae0e42..01f13c655dceb3ca16139e4246e69640771d8033 100644 (file)
@@ -276,7 +276,8 @@ int i18n_ubidi_get_text(const i18n_ubidi_h ubidi, char **text)
        retv_if(*text == NULL, I18N_ERROR_OUT_OF_MEMORY);
        memset(*text, 0x0, len+1);
 
-       strncpy(*text, _text, len);
+       COPY_STR(*text, _text, len + 1);
+       free(_text);
 
        return I18N_ERROR_NONE;
 }