summaryrefslogtreecommitdiff
path: root/kicad/pl-render.c
diff options
context:
space:
mode:
Diffstat (limited to 'kicad/pl-render.c')
-rw-r--r--kicad/pl-render.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index c56519c..ded0373 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -61,9 +61,11 @@ static char *expand(const struct pl_ctx *pl, const char *s,
unsigned size = 0;
unsigned len;
char *x;
+ bool do_free;
unsigned n;
while (1) {
+ do_free = 0;
p = strchr(s, '%');
if (!p)
break;
@@ -88,6 +90,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
for (sch = sheets; sch; sch = sch->next)
n++;
alloc_printf(&x, "%u", n);
+ do_free = 1;
break;
case 'P':
x = "%P"; // sheet path
@@ -101,6 +104,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
sch = sch->next)
n++;
alloc_printf(&x, "%u", n);
+ do_free = 1;
break;
case 'T':
x = (char *) sheet->title;
@@ -122,6 +126,8 @@ static char *expand(const struct pl_ctx *pl, const char *s,
s = p + 2;
memcpy(res + size, x, len);
size += len;
+ if (do_free)
+ free(x);
}
len = strlen(s);