summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-30 16:52:36 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-30 16:52:36 -0300
commit08106aa32ae67c2635f776417b016428f3476bd3 (patch)
tree957469adc8da1b0fb83e109f76d958a8e38c82a5
parent427e761a5836abb3696f20673450ff3c6b805c2f (diff)
downloadeeshow-08106aa32ae67c2635f776417b016428f3476bd3.tar.gz
eeshow-08106aa32ae67c2635f776417b016428f3476bd3.tar.bz2
eeshow-08106aa32ae67c2635f776417b016428f3476bd3.zip
fix remaining "direct" leaks in simplest use case
-rw-r--r--kicad/sexpr.c21
-rw-r--r--main.c4
2 files changed, 20 insertions, 5 deletions
diff --git a/kicad/sexpr.c b/kicad/sexpr.c
index 84871b9..9541ab8 100644
--- a/kicad/sexpr.c
+++ b/kicad/sexpr.c
@@ -43,6 +43,21 @@ struct sexpr_ctx {
/* ----- Parser ------------------------------------------------------------ */
+static bool pop(struct sexpr_ctx *ctx)
+{
+ struct stack *prev;
+
+ if (!ctx->sp->prev) {
+ error("too many )");
+ return 0;
+ }
+ prev = ctx->sp->prev;
+ free(ctx->sp);
+ ctx->sp = prev;
+ return 1;
+}
+
+
static void new_expr(struct sexpr_ctx *ctx)
{
struct stack *st = alloc_type(struct stack);
@@ -134,12 +149,8 @@ bool sexpr_parse(struct sexpr_ctx *ctx, const char *s)
new_expr(ctx);
break;
case ')':
- if (!ctx->sp->prev) {
+ if (!pop(ctx))
ctx->state = failed;
- error("too many )");
- break;
- }
- ctx->sp = ctx->sp->prev;
break;
case '"':
ctx->state = string;
diff --git a/main.c b/main.c
index 0b6dc74..a54bf6c 100644
--- a/main.c
+++ b/main.c
@@ -291,6 +291,8 @@ found:
if (!gfx_multi_sheet(gfx))
one_sheet = 1;
+ free(gfx_argv);
+
sch_init(&sch_ctx, !one_sheet);
if (!file_open(&sch_file, fn->sch, file_names.pro ? &pro_file : NULL))
return 1;
@@ -349,6 +351,8 @@ found:
sch_free(&sch_ctx);
lib_free(&lib);
+ if (pl)
+ pl_free(pl);
return retval;
}