SegFault in url.c when creating a temp file fails
Posted: 2013-04-04T20:46:36-07:00
In the below code, image is initialized to NULL. If AcquireUniqueFileResource or fdopen fails, the code tries to copy the filename to image->filename, which causes a SegFault because the destination is invalid. I ran into this because the system tmp directory was not writable by the user I was running this under (and it took me forever to figure this out because I figured RMagick was to blame).
Code: Select all
//url.c:147
image=(Image *) NULL;
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
file=(FILE *) NULL;
unique_file=AcquireUniqueFileResource(read_info->filename);
if (unique_file != -1)
file=fdopen(unique_file,"wb");
if ((unique_file == -1) || (file == (FILE *) NULL))
{
read_info=DestroyImageInfo(read_info);
(void) CopyMagickString(image->filename,read_info->filename,
MaxTextExtent);