summaryrefslogtreecommitdiff
path: root/kicad
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 /kicad
parent427e761a5836abb3696f20673450ff3c6b805c2f (diff)
downloadeeshow-08106aa32ae67c2635f776417b016428f3476bd3.tar.gz
eeshow-08106aa32ae67c2635f776417b016428f3476bd3.tar.bz2
eeshow-08106aa32ae67c2635f776417b016428f3476bd3.zip
fix remaining "direct" leaks in simplest use case
Diffstat (limited to 'kicad')
-rw-r--r--kicad/sexpr.c21
1 files changed, 16 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;