Evas_cache_image: fix cache double free problem
authorJiyoun Park <jy0703.park@samsung.com>
Fri, 15 Apr 2011 11:02:46 +0000 (20:02 +0900)
committerJiyoun Park <jy0703.park@samsung.com>
Fri, 15 Apr 2011 11:02:46 +0000 (20:02 +0900)
if second image object set file which is not exist,
it remove cache entry in cache.
first image object meet free problem when the object free

we fix second image object not deleting entry but making entry dirty
O

Change-Id: Icd874d8b4657209deb8e9df62d0fa4719d5f853a

src/lib/cache/evas_cache_image.c

index 5dcbd9b..7104d2f 100644 (file)
@@ -777,7 +777,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
    Image_Entry          *im;
    Evas_Image_Load_Opts  prevent = { 0, 0, 0, 0, { 0, 0, 0, 0 } };
    size_t                size;
-   int                   stat_done = 0;
+   int                   stat_done = 0, stat_failed = 0;
    size_t                file_length;
    size_t                key_length;
    struct stat           st;
@@ -878,14 +878,17 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
         int ok = 1;
         
         stat_done = 1;
-        if (stat(file, &st) < 0) goto on_stat_error;
+        if (stat(file, &st) < 0)
           {
-             if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0;
+              stat_failed = 1;
+              ok = 0;
           }
+        else if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0;
         if (ok) goto on_ok;
 
         _evas_cache_image_remove_activ(cache, im);
        _evas_cache_image_make_dirty(cache, im);
+        im = NULL;
      }
 
 #ifdef EVAS_FRAME_QUEUING
@@ -902,11 +905,14 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
         if (!stat_done)
           {
              stat_done = 1;
-             if (stat(file, &st) < 0) goto on_stat_error;
-             if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0;
+             if (stat(file, &st) < 0)
+               {
+                  stat_failed = 1;
+                  ok = 0;
           }
-        else
-           if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0;
+             else if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0;
+          }
+        else if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0;
 
         if (ok)
           {
@@ -914,9 +920,10 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
              _evas_cache_image_make_activ(cache, im, im->cache_key);
              goto on_ok;
           }
-
-        _evas_cache_image_entry_delete(cache, im);
+        _evas_cache_image_make_dirty(cache, im);
+        im = NULL;
      }
+   if (stat_failed) goto on_stat_error;
 
    if (!stat_done)
      {