• Federico Mena Quintero's avatar
    gitlab#323 - Limit the number of instancings through the <use> element · a9ca82a5
    Federico Mena Quintero authored
    A pathological SVG file can do this:
        <rect id="foo" .../>
        <g id="foo1">
          <use xlink:href="#foo"/>
          ... repeat 10 times ...
        <g id="foo2">
            <use xlink:href="#foo1"/>
            ... repeat 10 times ...
        <g id="foo3">
            <use xlink:href="#foo2"/>
            ... repeat 10 times ...
        ... etc ...
      <use xlink:href="#foo17"/>
    This would cause about 10^17 objects to be rendered.  While this does
    not exhaust memory (the objects are not instanced in memory), it would
    take a really long time to render that many objects.
    So, we now have a limit on up to 500,000 objects instanced through
    <use>.  We can tweak this limit later, or the way in which it is
    computed; the point is that we can now detect this situation and
    propagate an error upstream.
error.rs 2.56 KB