Fix to dereference NULL address of memory. 89/248789/3 accepted/tizen/unified/20201203.123821 submit/tizen/20201203.013717
authorJinWang An <jinwang.an@samsung.com>
Wed, 2 Dec 2020 08:12:16 +0000 (17:12 +0900)
committerJinWang An <jinwang.an@samsung.com>
Thu, 3 Dec 2020 01:35:56 +0000 (10:35 +0900)
Change-Id: Id6687a11b495c31f1f37b3b5f33671b8c7ff09c7
Signed-off-by: JinWang An <jinwang.an@samsung.com>
i18ninfo/i18ninfo.cpp

index 874c451..72a6cac 100644 (file)
@@ -1204,9 +1204,12 @@ i18n_uchar *_convert_unicode_numeric_values(const i18n_uchar *input, int32_t len
        if (length <= 0)
                return NULL;
        int32_t output_length = 1;
-
-       double *values = (double *) malloc(length * sizeof(double));
        int max_value_length = 0;
+       double *values = (double *) malloc(length * sizeof(double));
+       if (NULL == values) {
+               fprintf(stderr, "\nError: Out of memory.\n", values);
+               return NULL;
+       }
 
        /* Count output length */
        for (int32_t i = 0; i < length; ++i) {