mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
binpac: address linter warnings about use of sprintf()
This commit is contained in:
parent
d5f2c9c3a8
commit
49a96f5216
1 changed files with 5 additions and 5 deletions
|
@ -1068,17 +1068,17 @@ const ID* current_decl_id = 0;
|
||||||
|
|
||||||
int yyerror(const char msg[])
|
int yyerror(const char msg[])
|
||||||
{
|
{
|
||||||
char* msgbuf =
|
auto n = strlen(msg) + yyleng + 64;
|
||||||
new char[strlen(msg) + yyleng + 64];
|
char* msgbuf = new char[n];
|
||||||
|
|
||||||
if ( ! yychar || ! yytext || yytext[0] == '\0' )
|
if ( ! yychar || ! yytext || yytext[0] == '\0' )
|
||||||
sprintf(msgbuf, "%s, at end of file", msg);
|
snprintf(msgbuf, n, "%s, at end of file", msg);
|
||||||
|
|
||||||
else if ( yytext[0] == '\n' )
|
else if ( yytext[0] == '\n' )
|
||||||
sprintf(msgbuf, "%s, on previous line", msg);
|
snprintf(msgbuf, n, "%s, on previous line", msg);
|
||||||
|
|
||||||
else
|
else
|
||||||
sprintf(msgbuf, "%s, at or near \"%s\"", msg, yytext);
|
snprintf(msgbuf, n, "%s, at or near \"%s\"", msg, yytext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
extern int column;
|
extern int column;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue