ime: free allocated variables before return statement 49/280849/1 accepted/tizen/unified/20220908.013420
authorduna.oh <duna.oh@samsung.com>
Mon, 5 Sep 2022 04:19:11 +0000 (13:19 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 6 Sep 2022 01:55:54 +0000 (10:55 +0900)
To fix resource leak.

Change-Id: Icf1bdfdecebf14903c89c4f21fa92bbebc19513c

src/input_method/input_method.c
src/text_input/text_input.c

index 8eed2f2..138193f 100644 (file)
@@ -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,
index 05adda7..d25b1a4 100644 (file)
@@ -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,