diff --git a/MagickCore/cache.c b/MagickCore/cache.c
index bd06694..f033460 100644
--- a/MagickCore/cache.c
+++ b/MagickCore/cache.c
@@ -791,14 +791,14 @@
cache_info->filename);
return(MagickFalse);
}
- if (OpenPixelCacheOnDisk(cache_info,IOMode) == MagickFalse)
+ if (OpenPixelCacheOnDisk(cache_info,ReadMode) == MagickFalse)
{
blob=(unsigned char *) RelinquishMagickMemory(blob);
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
cache_info->cache_filename);
return(MagickFalse);
}
- if (OpenPixelCacheOnDisk(clone_info,IOMode) == MagickFalse)
+ if (OpenPixelCacheOnDisk(clone_info,WriteMode) == MagickFalse)
{
(void) ClosePixelCacheOnDisk(cache_info);
blob=(unsigned char *) RelinquishMagickMemory(blob);
@@ -972,7 +972,13 @@
}
if (clone_info->type == DiskCache)
{
- if (OpenPixelCacheOnDisk(clone_info,IOMode) == MagickFalse)
+ if ((cache_info->type == DiskCache) &&
+ (strcmp(cache_info->cache_filename,clone_info->cache_filename) == 0))
+ {
+ (void) ClosePixelCacheOnDisk(clone_info);
+ *clone_info->cache_filename='\0';
+ }
+ if (OpenPixelCacheOnDisk(clone_info,WriteMode) == MagickFalse)
{
if (cache_info->type == DiskCache)
(void) ClosePixelCacheOnDisk(cache_info);
@@ -4108,12 +4114,6 @@
"CacheResourcesExhausted","`%s'",image->filename);
return(MagickFalse);
}
- if (cache_info->type == DiskCache)
- {
- (void) ClosePixelCacheOnDisk(cache_info);
- *cache_info->cache_filename='\0';
- status=DiskToDiskPixelCacheClone(cache_info,&source_info,exception);
- }
if (OpenPixelCacheOnDisk(cache_info,mode) == MagickFalse)
{
RelinquishMagickResource(DiskResource,cache_info->length);