From: Jihoon Kim Date: Tue, 31 May 2022 10:13:04 +0000 (+0900) Subject: Fix memory leak when pos tag foreach function is not called X-Git-Tag: submit/tizen/20220621.070541~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8d938c0bbe4196a4d2e611ac9de44b62aed749b;p=platform%2Fcore%2Fuifw%2Fnlp.git Fix memory leak when pos tag foreach function is not called Change-Id: I95737b3ee4cc4fa32c9dcbd25b5ab9b371e93bee Signed-off-by: Jihoon Kim --- diff --git a/client/nlp_client.c b/client/nlp_client.c index c6ef7bb..3c69bea 100644 --- a/client/nlp_client.c +++ b/client/nlp_client.c @@ -86,6 +86,24 @@ static void process_pos_tag_result(nlp_h nh, bundle *msg) if (nh->pos_tag_result_cb) nh->pos_tag_result_cb((unsigned int)atoi(request_id), pos_tag_result_h, nh->pos_tag_result_data); + + GList* iter = NULL; + + if (g_list_length(glist) > 0) { + iter = g_list_first(glist); + + while (NULL != iter) { + pos_tag_pair = iter->data; + + /* next item */ + iter = g_list_next(iter); + + free(pos_tag_pair); + } + + g_list_free(glist); + glist = NULL; + } } static void process_word_tokenize_result(nlp_h nh, bundle *msg) @@ -412,12 +430,7 @@ int nlp_foreach_pos_tag(nlp_pos_tag_result_h pos_tag_result_h, nlp_pos_tag_forea /* next item */ iter = g_list_next(iter); - - free(pos_tag_pair); } - - g_list_free(glist); - glist = NULL; } return NLP_ERROR_NONE;