summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-19 05:43:16 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-19 05:43:16 (GMT)
commitb833d34d8572bf8f8ff9c963b34d57122901a228 (patch)
tree2f90ecd8eeaf254b4178beb31ad8bae1946c9a71 /kicad
parentb35bfa7633e1df47e2df699942f13ad2398ccd5e (diff)
downloadeeshow-b833d34d8572bf8f8ff9c963b34d57122901a228.zip
eeshow-b833d34d8572bf8f8ff9c963b34d57122901a228.tar.gz
eeshow-b833d34d8572bf8f8ff9c963b34d57122901a228.tar.bz2
kicad/sch-parse.c (parse_line): use "n" only for %n
Else, we need to ensure it never gets set by partially accepted lines, like Comment1 "" with format string Comment%d %[\"] Just avoiding reuse of "n" is easier and thus safer.
Diffstat (limited to 'kicad')
-rw-r--r--kicad/sch-parse.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kicad/sch-parse.c b/kicad/sch-parse.c
index 86c8ed2..76f82b1 100644
--- a/kicad/sch-parse.c
+++ b/kicad/sch-parse.c
@@ -464,7 +464,8 @@ static bool parse_line(const struct file *file, void *user, const char *line)
{
struct sch_ctx *ctx = user;
struct sch_obj *obj = &ctx->obj;
- int n = 0;
+ int n = 0; /* use ONLY for %n */
+ int i;
char *s, *italic;
int bold;
@@ -607,13 +608,11 @@ static bool parse_line(const struct file *file, void *user, const char *line)
ctx->curr_sheet->title = s;
return 1;
}
- if (sscanf(line, "Comment%*d \"\"%n", &n) == 0 && n)
- return 1;
- if (sscanf(line, "Comment%d \"%m[^\"]\"", &n, &s) == 2) {
- if (n < 0)
+ if (sscanf(line, "Comment%d \"%m[^\"]\"", &i, &s) == 2) {
+ if (i < 0)
fatal("%s:%u: invalid comment index %d",
- file->name, file->lineno, n);
- add_comment(ctx->curr_sheet, n, s);
+ file->name, file->lineno, i);
+ add_comment(ctx->curr_sheet, i, s);
return 1;
}
if (sscanf(line, "$EndDescr%n", &n) || !n)