elm_image: stop preloading before intenal_file_set as it may hit to-be-freed memory 35/154635/2 submit/tizen/20171012.123430
authorJeonghyun Yun <jh0506.yun@samsung.com>
Wed, 11 Oct 2017 01:45:57 +0000 (10:45 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 12 Oct 2017 00:38:16 +0000 (00:38 +0000)
Change-Id: I8df88ac5736058983a5c3db1addd573402b214bc
Signed-off-by: Jeonghyun Yun <jh0506.yun@samsung.com>
src/lib/elm_image.c

index 45332ae..5b758fb 100644 (file)
@@ -1007,6 +1007,10 @@ _elm_image_smart_download_done(void *data, Elm_Url *url, Eina_Binbuf *download)
    size_t length;
    Eina_Bool ret = EINA_FALSE;
 
+   /* stop preloading as it may hit to-be-freed memory */
+   if (sd->preload_status == ELM_IMAGE_PRELOADING)
+     evas_object_image_preload(sd->img, EINA_TRUE);
+
    free(sd->remote_data);
    length = eina_binbuf_length_get(download);
    sd->remote_data = eina_binbuf_string_steal(download);
@@ -1073,6 +1077,12 @@ _elm_image_efl_file_file_set(Eo *obj, Elm_Image_Data *sd, const char *file, cons
    Eina_Bool ret = EINA_FALSE;
    unsigned int i;
 
+   _async_cancel(sd);
+
+   /* stop preloading as it may hit to-be-freed memory */
+   if (sd->preload_status == ELM_IMAGE_PRELOADING)
+     evas_object_image_preload(sd->img, EINA_TRUE);
+
    if (sd->remote) _elm_url_cancel(sd->remote);
    sd->remote = NULL;
 
@@ -1095,8 +1105,6 @@ _elm_image_efl_file_file_set(Eo *obj, Elm_Image_Data *sd, const char *file, cons
           break;
        }
 
-   _async_cancel(sd);
-
    if (!sd->async_enable)
      ret = _elm_image_smart_internal_file_set(obj, sd, file, NULL, key);
    else
@@ -1151,11 +1159,15 @@ _elm_image_mmap_set(Eo *obj, Elm_Image_Data *sd, const Eina_File *f, const char
 {
    Eina_Bool ret;
 
+   _async_cancel(sd);
+
+   /* stop preloading as it may hit to-be-freed memory */
+   if (sd->preload_status == ELM_IMAGE_PRELOADING)
+     evas_object_image_preload(sd->img, EINA_TRUE);
+
    if (sd->remote) _elm_url_cancel(sd->remote);
    sd->remote = NULL;
 
-   _async_cancel(sd);
-
    if (!sd->async_enable)
      ret = _elm_image_smart_internal_file_set(obj, sd, eina_file_filename_get(f), f, key);
    else