From a7b78fe679e1e405812d49fe44c870a822a1ac79 Mon Sep 17 00:00:00 2001 From: JinWang An Date: Wed, 2 Dec 2020 17:12:16 +0900 Subject: [PATCH] Fix to dereference NULL address of memory. Change-Id: Id6687a11b495c31f1f37b3b5f33671b8c7ff09c7 Signed-off-by: JinWang An --- i18ninfo/i18ninfo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/i18ninfo/i18ninfo.cpp b/i18ninfo/i18ninfo.cpp index 874c451..72a6cac 100644 --- a/i18ninfo/i18ninfo.cpp +++ b/i18ninfo/i18ninfo.cpp @@ -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) { -- 2.7.4