mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
style: prefer snprintf to sprintf
* src/symtab.c (dummy_symbol_get): There's no need for the buffer to be so big and static. Use snprintf for safety.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
# gnulib modules used by this package.
|
||||
gnulib_modules='
|
||||
argmatch array-list assert
|
||||
argmatch array-list assert assure
|
||||
bitsetv
|
||||
calloc-posix close closeout config-h c-strcase
|
||||
configmake
|
||||
|
||||
1
lib/.gitignore
vendored
1
lib/.gitignore
vendored
@@ -318,3 +318,4 @@
|
||||
/rename.c
|
||||
/rmdir.c
|
||||
/same-inode.h
|
||||
/assure.h
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include <assure.h>
|
||||
#include <hash.h>
|
||||
|
||||
#include "complain.h"
|
||||
@@ -865,9 +866,9 @@ dummy_symbol_get (location loc)
|
||||
{
|
||||
/* Incremented for each generated symbol. */
|
||||
static int dummy_count = 0;
|
||||
static char buf[256];
|
||||
|
||||
sprintf (buf, "$@%d", ++dummy_count);
|
||||
char buf[32];
|
||||
int len = snprintf (buf, sizeof buf, "$@%d", ++dummy_count);
|
||||
assure (len < sizeof buf);
|
||||
symbol *sym = symbol_get (buf, loc);
|
||||
sym->content->class = nterm_sym;
|
||||
sym->content->number = nvars++;
|
||||
|
||||
Reference in New Issue
Block a user