From bcd2f95e229f6aa76765cdd9f914dd71a5936c24 Mon Sep 17 00:00:00 2001 From: "duna.oh" Date: Mon, 5 Sep 2022 13:19:11 +0900 Subject: [PATCH] ime: free allocated variables before return statement To fix resource leak. Change-Id: Icf1bdfdecebf14903c89c4f21fa92bbebc19513c --- src/input_method/input_method.c | 5 ++++- src/text_input/text_input.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/input_method/input_method.c b/src/input_method/input_method.c index 8eed2f2..138193f 100644 --- a/src/input_method/input_method.c +++ b/src/input_method/input_method.c @@ -221,8 +221,10 @@ ds_tizen_input_method_create_context(struct ds_tizen_input_method *input_method) ds_inf("ds_tizen_input_method_create_context"); context = calloc(1, sizeof *context); - if (context == NULL) + if (context == NULL) { + ds_err("calloc() failed. ds_tizen_input_method_context"); return NULL; + } binding = input_method->resource; if (!binding) return NULL; @@ -230,6 +232,7 @@ ds_tizen_input_method_create_context(struct ds_tizen_input_method *input_method) &zwp_input_method_context_v1_interface, INPUT_METHOD_VERSION, 0); if (context->resource == NULL) { ds_err("context. wl_resource_create() failed."); + free(context); return NULL; } wl_resource_set_implementation(context->resource, &context_impl, diff --git a/src/text_input/text_input.c b/src/text_input/text_input.c index 05adda7..d25b1a4 100644 --- a/src/text_input/text_input.c +++ b/src/text_input/text_input.c @@ -448,6 +448,7 @@ text_input_manager_handle_create_text_input(struct wl_client *wl_client, if (text_input->resource == NULL) { ds_err("text_input. wl_resource_create() failed."); wl_client_post_no_memory(wl_client); + free(text_input); return; } wl_resource_set_implementation(text_input->resource, &text_input_impl, -- 2.7.4