Include declarations.
*/
#include "MagickCore/studio.h"
-#include "MagickCore/nt-base-private.h"
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#include "MagickCore/cache.h"
#include "MagickCore/log.h"
#include "MagickCore/magick.h"
#include "MagickCore/memory_.h"
+#include "MagickCore/nt-base-private.h"
#include "MagickCore/policy.h"
#include "MagickCore/resource_.h"
#include "MagickCore/semaphore.h"
magick_info=GetMagickInfo(blob_info->magick,exception);
if (magick_info == (const MagickInfo *) NULL)
{
- blob_info=DestroyImageInfo(blob_info);
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
- image_info->filename);
+ blob_info->magick);
+ blob_info=DestroyImageInfo(blob_info);
return((Image *) NULL);
}
if (GetMagickBlobSupport(magick_info) != MagickFalse)
*images;
/*
- Restore original filenames.
+ Restore original filenames and image format.
*/
for (images=GetFirstImageInList(image); images != (Image *) NULL; )
{
- (void) CopyMagickMemory(images->filename,image_info->filename,
- sizeof(images->filename));
- (void) CopyMagickMemory(images->magick_filename,image_info->filename,
- sizeof(images->magick_filename));
+ (void) CopyMagickString(images->filename,image_info->filename,
+ MaxTextExtent);
+ (void) CopyMagickString(images->magick_filename,image_info->filename,
+ MaxTextExtent);
+ (void) CopyMagickString(images->magick,magick_info->name,
+ MaxTextExtent);
images=GetNextImageInList(images);
}
}
RelinquishMagickResource(MapResource,image->blob->length);
}
if (image->blob->semaphore != (SemaphoreInfo *) NULL)
- DestroySemaphoreInfo(&image->blob->semaphore);
+ RelinquishSemaphoreInfo(&image->blob->semaphore);
image->blob->signature=(~MagickSignature);
image->blob=(BlobInfo *) RelinquishMagickMemory(image->blob);
}
if (blob_info->mapped != MagickFalse)
{
(void) UnmapBlob(blob_info->data,blob_info->length);
+ blob_info->data=(unsigned char *) NULL;
RelinquishMagickResource(MapResource,blob_info->length);
}
blob_info->mapped=MagickFalse;
blob=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*blob));
if (blob == (unsigned char *) NULL)
{
+ file=close(file);
ThrowFileException(exception,ResourceLimitError,"MemoryAllocationFailed",
filename);
return(MagickFalse);
blob_info->properties.st_ctime=time((time_t *) NULL);
blob_info->debug=IsEventLogging();
blob_info->reference_count=1;
- blob_info->semaphore=AllocateSemaphoreInfo();
+ blob_info->semaphore=AcquireSemaphoreInfo();
blob_info->signature=MagickSignature;
}
\f
{
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
- image->filename);
+ image->magick);
+ blob_info=DestroyImageInfo(blob_info);
return(blob);
}
(void) CopyMagickString(blob_info->magick,image->magick,MaxTextExtent);
(void) FormatLocaleString(image->filename,MaxTextExtent,"%s:%s",
image->magick,unique);
status=WriteImage(blob_info,image,exception);
+ (void) CloseBlob(image);
(void) fclose(blob_info->file);
if (status != MagickFalse)
blob=FileToBlob(unique,~0UL,length,exception);
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
if ((file == -1) || (i < length))
{
+ if (file != -1)
+ file=close(file);
ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename);
return(MagickFalse);
}
{
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
- images->filename);
+ images->magick);
+ blob_info=DestroyImageInfo(blob_info);
return(blob);
}
if (GetMagickAdjoin(magick_info) == MagickFalse)
(void) FormatLocaleString(filename,MaxTextExtent,"%s:%s",
images->magick,unique);
status=WriteImages(blob_info,images,filename,exception);
+ (void) CloseBlob(images);
(void) fclose(blob_info->file);
if (status != MagickFalse)
blob=FileToBlob(unique,~0UL,length,exception);
if (((int) magick[0] == 0x1F) && ((int) magick[1] == 0x8B) &&
((int) magick[2] == 0x08))
{
- (void) fclose(image->blob->file_info.file);
+ if (image->blob->file_info.file != (FILE *) NULL)
+ (void) fclose(image->blob->file_info.file);
+ image->blob->file_info.file=(FILE *) NULL;
image->blob->file_info.gzfile=gzopen(filename,type);
if (image->blob->file_info.gzfile != (gzFile) NULL)
image->blob->type=ZipStream;
#if defined(MAGICKCORE_BZLIB_DELEGATE)
if (strncmp((char *) magick,"BZh",3) == 0)
{
- (void) fclose(image->blob->file_info.file);
+ if (image->blob->file_info.file != (FILE *) NULL)
+ (void) fclose(image->blob->file_info.file);
+ image->blob->file_info.file=(FILE *) NULL;
image->blob->file_info.bzfile=BZ2_bzopen(filename,type);
if (image->blob->file_info.bzfile != (BZFILE *) NULL)
image->blob->type=BZipStream;
return(-1);
case FileStream:
{
+ if ((whence == SEEK_SET) && (offset < 0))
+ return(-1);
if (fseek(image->blob->file_info.file,offset,whence) < 0)
return(-1);
image->blob->offset=TellBlob(image);