Skip to content

Commit

Permalink
Avoid uninitialized scope prefix leading to UB on memcpy, though len …
Browse files Browse the repository at this point in the history
…is 0
  • Loading branch information
mikkelfj committed Oct 23, 2023
1 parent aefd0c8 commit d533710
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Fix regression where empty namespace in schema does not reset root scope
correctly in parser (#265).
- Fix lexer checks that breaks with UTF-8, notably UTF-8 schema comments (#267).
- Fix UB in memcpy(p, 0, 0) by initializing scope prefix (mostly to silence sanitizers).

## [0.6.1]

Expand Down
2 changes: 2 additions & 0 deletions src/compiler/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,8 @@ int fb_init_parser(fb_parser_t *P, fb_options_t *opts, const char *name,
P->schema.name.name.s.s = s;
P->schema.name.name.s.len = (int)n;
checkmem((P->schema.errorname = fb_create_basename(name, name_len, "")));
P->schema.prefix.s = "";
P->schema.prefix.len = 0;
if (opts->ns) {
P->schema.prefix.s = (char *)opts->ns;
P->schema.prefix.len = (int)strlen(opts->ns);
Expand Down

0 comments on commit d533710

Please sign in to comment.