]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix race condition/data corruption in imagecache
authorFlole998 <Flole998@users.noreply.github.com>
Thu, 27 Oct 2022 20:01:31 +0000 (22:01 +0200)
committerGitHub <noreply@github.com>
Thu, 27 Oct 2022 20:01:31 +0000 (22:01 +0200)
src/imagecache.c

index 7a93d6791fbc7437bbabdfb541f0aa68e75e3a2a..67d0a937ec19396c8403561b0be8985a7d1327c9 100644 (file)
@@ -573,8 +573,8 @@ imagecache_done ( void )
     }
     imagecache_destroy(img, 0);
   }
-  tvh_mutex_unlock(&imagecache_lock);
   SKEL_FREE(imagecache_skel);
+  tvh_mutex_unlock(&imagecache_lock);
 }
 
 
@@ -680,12 +680,12 @@ imagecache_get_id ( const char *url )
   if (!imagecache_conf.enabled && strncasecmp(url, "file://", 7))
     return 0;
 
+  tvh_mutex_lock(&imagecache_lock);
+  
   /* Skeleton */
   SKEL_ALLOC(imagecache_skel);
   imagecache_skel->url = url;
 
-  tvh_mutex_lock(&imagecache_lock);
-
   /* Create/Find */
   i = RB_INSERT_SORTED(&imagecache_by_url, imagecache_skel, url_link, url_cmp);
   if (!i) {