From 6631ce981ba01a14117dd1976d040283bd643761 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jancsika@yahoo.com>
Date: Sun, 22 Jun 2014 16:21:11 -0400
Subject: [PATCH] fixed some stray memory allocation errors

---
 pd/src/g_template.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pd/src/g_template.c b/pd/src/g_template.c
index 8f7b9125a..18c009484 100644
--- a/pd/src/g_template.c
+++ b/pd/src/g_template.c
@@ -1136,9 +1136,11 @@ void *svg_new(t_pd *parent, t_symbol *s, int argc, t_atom *argv)
             x->x_type == gensym("ellipse"))
         {
             nxy = 4;
+            if (argc > 4) argc = 4;
         }
         x->x_nargs = nxy;
     }
+    post("nxy is %d", nxy);
     x->x_vec = (t_fielddesc *)t_getbytes(nxy * sizeof(t_fielddesc));
     if (x->x_type == gensym("rect") ||
         x->x_type == gensym("circle") ||
@@ -1202,9 +1204,10 @@ void *svg_new(t_pd *parent, t_symbol *s, int argc, t_atom *argv)
 
     x->x_ndash = 0;
     x->x_strokedasharray =
-        (t_fielddesc *)t_getbytes(1 * sizeof(t_fielddesc));
+        (t_fielddesc *)t_getbytes(x->x_ndash * sizeof(t_fielddesc));
     x->x_transform_n = 0;
-    x->x_transform = (t_fielddesc *)t_getbytes(1 * sizeof(t_fielddesc));
+    x->x_transform = (t_fielddesc *)t_getbytes(x->x_transform_n *
+        sizeof(t_fielddesc));
     return (x);
 }
 
-- 
GitLab