Fix composit_image making error handling problem 20/270320/1
authorJunkyeong, Kim <jk0430.kim@samsung.com>
Fri, 28 Jan 2022 04:46:05 +0000 (13:46 +0900)
committerJunkyeong, Kim <jk0430.kim@samsung.com>
Fri, 28 Jan 2022 04:46:12 +0000 (13:46 +0900)
stop compositing if cannot get destination postion.
execute tbm_surface unref if compositing failed.

Change-Id: I1f9a55ef49517db8c3867a0a428bb92e658446fe
Signed-off-by: Junkyeong, Kim <jk0430.kim@samsung.com>
src/e_mod_rdp.c

index d3decbb..d175bb6 100644 (file)
@@ -447,13 +447,13 @@ _e_rdp_output_image_src_crop_get(E_Hwc_Window *hwc_window, Eina_Rectangle *fit,
      }
 }
 
-static void
+static Eina_Bool
 _e_rdp_output_center_rect_get (int src_w, int src_h, int dst_w, int dst_h, Eina_Rectangle *fit)
 {
    float rw, rh;
 
    if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0 || !fit)
-     return;
+     return EINA_FALSE;
 
    rw = (float)src_w / dst_w;
    rh = (float)src_h / dst_h;
@@ -482,6 +482,8 @@ _e_rdp_output_center_rect_get (int src_w, int src_h, int dst_w, int dst_h, Eina_
 
    if (fit->x % 2)
      fit->x = fit->x - 1;
+
+   return EINA_TRUE;
 }
 
 static void
@@ -620,7 +622,11 @@ _e_rdp_pixman_output_image_composite_cursor(E_Rdp_Output *output, E_Hwc_Window *
      }
 
    _e_rdp_output_image_src_crop_get(hwc_window, &src_crop, &showing_pos, primary_w, primary_h);
-   _e_rdp_output_center_rect_get(primary_w, primary_h, pix_w, pix_h, &dst_pos);
+   if (_e_rdp_output_center_rect_get(primary_w, primary_h, pix_w, pix_h, &dst_pos) == EINA_FALSE)
+     {
+        pixman_image_unref(pix_shm_src);
+        return EINA_FALSE;
+     }
    _e_rdp_output_image_dst_crop_get(hwc_window, img_w, img_h, primary_w, primary_h, &dst_pos, &showing_pos, &dst_crop, 0);
 
    _e_rdp_output_image_composite(pix_shm_src, pix_surface,
@@ -644,7 +650,6 @@ _e_rdp_pixman_output_image_composite(E_Rdp_Output *output, E_Hwc_Window *hwc_win
    tbm_surface_info_s info;
    pixman_image_t *pix_surface_src = NULL;
    pixman_format_code_t pix_format = 0;
-   int err = 0;
 
    tbm_surface = hwc_window->display.buffer.tsurface;
    if (!tbm_surface)
@@ -652,28 +657,33 @@ _e_rdp_pixman_output_image_composite(E_Rdp_Output *output, E_Hwc_Window *hwc_win
 
    tbm_surface_internal_ref(tbm_surface);
 
-   err = tbm_surface_map(tbm_surface, TBM_SURF_OPTION_READ, &info);
-   if (err)
-     return EINA_FALSE;
+   if (tbm_surface_map(tbm_surface, TBM_SURF_OPTION_READ, &info) != TBM_SURFACE_ERROR_NONE)
+     {
+        tbm_surface_internal_unref(tbm_surface);
+        return EINA_FALSE;
+     }
 
    pix_format = _e_rdp_pixman_format_get(info.format);
    if (pix_format == 0)
      {
         ERR("not supported format");
-        tbm_surface_unmap(tbm_surface);
-        return EINA_FALSE;
+        goto error;
      }
 
    pix_surface_src = pixman_image_create_bits(pix_format, info.width, info.height, (uint32_t *)info.planes[0].ptr, info.planes[0].stride);
    if (pix_surface_src == NULL)
      {
         ERR("create pixman image failed");
-        tbm_surface_unmap(tbm_surface);
-        return EINA_FALSE;
+        goto error;
      }
 
    _e_rdp_output_image_src_crop_get(hwc_window, &src_crop, &showing_pos, primary_w, primary_h);
    _e_rdp_output_center_rect_get(primary_w, primary_h, pix_w, pix_h, &dst_pos);
+   if (_e_rdp_output_center_rect_get(primary_w, primary_h, pix_w, pix_h, &dst_pos) == EINA_FALSE)
+     {
+        pixman_image_unref(pix_surface_src);
+        goto error;
+     }
    _e_rdp_output_image_dst_crop_get(hwc_window, info.width, info.height, primary_w, primary_h, &dst_pos, &showing_pos, &dst_crop, 0);
 
    _e_rdp_output_image_composite(pix_surface_src, pix_surface,
@@ -686,6 +696,11 @@ _e_rdp_pixman_output_image_composite(E_Rdp_Output *output, E_Hwc_Window *hwc_win
    tbm_surface_internal_unref(tbm_surface);
 
    return EINA_TRUE;
+
+error:
+   tbm_surface_unmap(tbm_surface);
+   tbm_surface_internal_unref(tbm_surface);
+   return EINA_FALSE;
 }
 
 static int