Commit a347cc80c for imagemagick.org

commit a347cc80c671182fbf24ed21f0f64042815f0e38
Author: Artem Lytkin <146867384+4RH1T3CT0R7@users.noreply.github.com>
Date:   Sat Sep 26 04:39:40 2026 +0300

    Avoid copying the MVG text into every graphic context (#8975)

    RenderMVGContent parses its own copy of the MVG document, but the first
    CloneDrawInfo also copies draw_info->primitive into graphic_context[0].
    From there the whole document is duplicated again on every push
    graphic-context and on the extra clones made for each wide stroke, which
    makes large MVG files quadratic. Nothing reads the copy, and the nested
    renders (clip-path, mask, pattern, use) set their own primitive, so free
    it right after the clone.

    https://github.com/ImageMagick/ImageMagick/issues/8443

diff --git a/MagickCore/draw.c b/MagickCore/draw.c
index fc3acfa41..2375bafb5 100644
--- a/MagickCore/draw.c
+++ b/MagickCore/draw.c
@@ -2657,6 +2657,8 @@ static MagickBooleanType RenderMVGContent(Image *image,
   mvg_info.extent=(&number_points);
   mvg_info.exception=exception;
   graphic_context[n]=CloneDrawInfo((ImageInfo *) NULL,draw_info);
+  if (graphic_context[n]->primitive != (char *) NULL)
+    graphic_context[n]->primitive=DestroyString(graphic_context[n]->primitive);
   graphic_context[n]->viewbox=image->page;
   if ((image->page.width == 0) || (image->page.height == 0))
     {