Skip to content

Commit

Permalink
Corrected patch that was added for #6538 to make sure we only free th…
Browse files Browse the repository at this point in the history
…e memory when the blob was never used.
  • Loading branch information
dlemstra committed May 5, 2024
1 parent bacef9e commit 6e39633
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions MagickCore/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,10 @@ MagickExport void *DetachBlob(BlobInfo *blob_info)
}
blob_info->mapped=MagickFalse;
blob_info->length=0;
/*
We should not reset blob_info->extent because we use it to check if the
blob was opened inside ImagesToBlob and ImagesToBlob.
*/
blob_info->offset=0;
blob_info->mode=UndefinedBlobMode;
blob_info->eof=MagickFalse;
Expand Down Expand Up @@ -2101,6 +2105,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,
{
(void) CloseBlob(image);
image->blob->exempt=MagickTrue;
image->blob->extent=0;
*image->filename='\0';
status=WriteImage(blob_info,image,exception);
*length=image->blob->length;
Expand All @@ -2112,7 +2117,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,
else
blob=ResizeQuantumMemory(blob,*length+1,sizeof(unsigned char));
}
else if (status == MagickFalse)
else if ((status == MagickFalse) && (image->blob->extent == 0))
blob_info->blob=RelinquishMagickMemory(blob_info->blob);
}
}
Expand Down Expand Up @@ -2508,6 +2513,7 @@ MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images,
{
(void) CloseBlob(images);
images->blob->exempt=MagickTrue;
images->blob->extent=0;
*images->filename='\0';
status=WriteImages(blob_info,images,images->filename,exception);
*length=images->blob->length;
Expand All @@ -2519,7 +2525,7 @@ MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images,
else
blob=ResizeQuantumMemory(blob,*length+1,sizeof(unsigned char));
}
else if (status == MagickFalse)
else if ((status == MagickFalse) && (images->blob->extent == 0))
blob_info->blob=RelinquishMagickMemory(blob_info->blob);
}
}
Expand Down

0 comments on commit 6e39633

Please sign in to comment.