From 13504c2066b13e28ddfa2156b6f1bbfe4d13f31a Mon Sep 17 00:00:00 2001 From: JinWang An Date: Tue, 22 Sep 2020 02:12:47 +0900 Subject: [PATCH] Add free() to fix memory leak at i18n_measure_format_format_measures Change-Id: If6a39bf2776d2bbd9834ea28e190b3f534532648 Signed-off-by: JinWang An --- src/utils_i18n_measure_format.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils_i18n_measure_format.cpp b/src/utils_i18n_measure_format.cpp index ece211c..350ab0f 100644 --- a/src/utils_i18n_measure_format.cpp +++ b/src/utils_i18n_measure_format.cpp @@ -242,9 +242,18 @@ int i18n_measure_format_format_measures(const i18n_measure_format_h measure_form const i18n_uchar *uchar_result = (i18n_uchar *)result.getTerminatedBuffer(); - retv_if(uchar_result == NULL, I18N_ERROR_INVALID_PARAMETER); + if(uchar_result == NULL) { + ERR("result.getTerminatedBuffer() == NULL"); + free(measure_array); + return I18N_ERROR_INVALID_PARAMETER; + } + *output_length = i18n_ustring_get_length(uchar_result); - retv_if(append_to_size < *output_length, I18N_ERROR_BUFFER_OVERFLOW); + if(append_to_size < *output_length) { + ERR("append_to_size < *output_length"); + free(measure_array); + return I18N_ERROR_BUFFER_OVERFLOW; + } if (*output_length > 0) i18n_ustring_copy_n(append_to, uchar_result, append_to_size); -- 2.7.4