From: Cristy Date: Fri, 12 Apr 2019 16:18:15 +0000 (-0400) Subject: Don't call fstat() on a closed file X-Git-Tag: 7.0.8-40~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb957066b3a72716158bbbb08185b5ee52be185a;p=imagemagick Don't call fstat() on a closed file --- diff --git a/MagickCore/blob.c b/MagickCore/blob.c index 9f04f1d16..77868e1bc 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -1823,7 +1823,16 @@ MagickExport MagickSizeType GetBlobSize(const Image *image) } case FileStream: { - if (fstat(fileno(blob_info->file_info.file),&blob_info->properties) == 0) + int + file_descriptor; + + extent=(MagickSizeType) blob_info->properties.st_size; + if (extent == 0) + extent=blob_info->size; + file_descriptor=fileno(blob_info->file_info.file); + if (file_descriptor == -1) + break; + if (fstat(file_descriptor,&blob_info->properties) == 0) extent=(MagickSizeType) blob_info->properties.st_size; break; }