Commit da4ca6b71 for imagemagick.org
commit da4ca6b71ec9509137f700414ebb1291af099a29
Author: Cristy <urban-warrior@imagemagick.org>
Date: Sat Sep 19 09:52:43 2026 -0400
optimize file read checking
diff --git a/MagickCore/blob.c b/MagickCore/blob.c
index 78f6d9a0e..fa004672a 100644
--- a/MagickCore/blob.c
+++ b/MagickCore/blob.c
@@ -1541,19 +1541,13 @@ MagickExport void *FileToBlob(const char *filename,const size_t extent,
}
if (LocaleCompare(filename,"-") != 0)
file=close_utf8(file);
- if (count < 0)
- {
- blob=(unsigned char *) RelinquishMagickMemory(blob);
- ThrowFileException(exception,BlobError,"UnableToReadBlob",filename);
- return(NULL);
- }
if (blob == (unsigned char *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
return(NULL);
}
- if (file == -1)
+ if ((count < 0) || (file == -1))
{
blob=(unsigned char *) RelinquishMagickMemory(blob);
ThrowFileException(exception,BlobError,"UnableToReadBlob",filename);