summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-30 20:37:20 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-08-30 20:40:06 (GMT)
commit4003ac990ea31e7192f4679a6902cdf568eb58eb (patch)
treece5c5bdcc82ba37e3e3fc5ac1ea4ed71ffa0e726 /kicad
parentafd34a0fd3632985d106c4532bc5f96c1fd6bbfb (diff)
downloadeeshow-4003ac990ea31e7192f4679a6902cdf568eb58eb.zip
eeshow-4003ac990ea31e7192f4679a6902cdf568eb58eb.tar.gz
eeshow-4003ac990ea31e7192f4679a6902cdf568eb58eb.tar.bz2
kicad/sch-parse.c (parse_field): free "field" on all rejected lines
Note that parse_field rejecting a lines doesn't mean there is anything wrong with it, we could leak a fair number of fields this way. For eeshow -N 1 ../../n9/ee/hw/neo900.pro -- pdf >/dev/null 142,128 bytes in 2,961 blocks are definitely lost in loss record 347 of 347
Diffstat (limited to 'kicad')
-rw-r--r--kicad/sch-parse.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kicad/sch-parse.c b/kicad/sch-parse.c
index 3525690..ddca26d 100644
--- a/kicad/sch-parse.c
+++ b/kicad/sch-parse.c
@@ -127,6 +127,7 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
txt = &field->txt;
txt->s = NULL;
+ /* ignore fields with empty string as content */
if (sscanf(line, "F %d \"\" %c %d %d %u %u %c %c%c%c",
&n, &hv, &txt->x, &txt->y, &txt->size, &flags, &hor, &vert,
&italic, &bold) == 10) {
@@ -134,13 +135,17 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
return 1;
}
- if (sscanf(line, "F %d \"%n", &n, &pos) != 1 || !pos)
+ if (sscanf(line, "F %d \"%n", &n, &pos) != 1 || !pos) {
+ free(field);
return 0;
+ }
for (p = line + pos; *p && *p != '"'; p++)
if (*p == '\\' && p[1])
p++;
- if (*p != '"')
+ if (*p != '"') {
+ free(field);
return 0;
+ }
len = p - (line + pos);
s = alloc_size(len + 1);
@@ -151,6 +156,7 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
&hv, &txt->x, &txt->y, &txt->size, &flags,
&hor, &vert, &italic, &bold) != 9) {
free(s);
+ free(field);
return 0;
}
txt->s = s;