Skip to content

Commit

Permalink
Fix #define parsing bug
Browse files Browse the repository at this point in the history
Commit eb41365 introduced a bug in
`#define` parsing wherein a null terminator would be written into the
parse input stream after the expanded definition. The intention of the
buggy commit was to eliminate a (wise) warning about using the source
length as the buffer length in a `strncpy` operation; using memcpy here
is probably the more-correct solution as we already know all the lengths
involved.
  • Loading branch information
tophyr committed Dec 5, 2023
1 parent dfa4949 commit 3c8feee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ add_input(char *p)
}
outp -= l;
nbuf += l;
strcpy(outp, p);
memcpy(outp, p, l);
}

#define DEFHASH 1999
Expand Down

0 comments on commit 3c8feee

Please sign in to comment.