Page 1 of 1

Svg files without width and height attributes cause Memory leak / Windows crash

Posted: 2016-02-12T04:35:20-07:00
by Roman
Hi All,

On reading some svg files ImageMagick crashes a process (if we are using 32-bit process) or crashes Windows 10 (if we are using 64-bit process). To reproduce the issue you can use this code

static void Main(string[] args)
{
for (int i=0; i<100000; i++)
{
MagickImage oMagic = new MagickImage(@"C:\Users\Roman\Documents\tasks\test\2137.svg");

oMagic.Dispose();
}
}

On 32-bit process error is "failed to alllocate 4088 bytes (alignment: 4096): Not enough space.

Tested with the latest Magick.NET-7.0.0.0101-Q16-x64.zip. It's needed to say that standard ImageMagick's command convert also doesn't work (error is: "no images defined").

In this svg file height and width attributes are absent in <svg> element. If I add height and width then everything works as expected.

I think it's ok to have ImageMagick's error "no images defined" but it's not OK to have memory leak. You can take svg to test here: http://1drv.ms/1PqVkfT

Thanks.

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Posted: 2016-02-12T05:16:55-07:00
by dlemstra
Thank you for reporting this. I just pushed a patch to our ImageMagick GIT repository to fix this. I will publish a new release of Magick.NET this weekend that will include this fix.

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Posted: 2016-02-12T05:25:58-07:00
by Roman
Great. Thank you!

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Posted: 2016-02-15T06:19:28-07:00
by Roman
Just checked update -> now the above code throws the 'ImageMagick.MagickMissingDelegateErrorException' exception. I assume that it's the expected behavior. Thanks again.

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Posted: 2016-02-15T06:36:26-07:00
by dlemstra
That is indeed the expected behavior.