bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 7/8] bison: please address sanitizer


From: Akim Demaille
Subject: [PATCH 7/8] bison: please address sanitizer
Date: Sun, 27 May 2018 10:55:34 +0200

* src/parse-gram.y (add_param): Asan does not like that the second
argument of strspn is not 0-terminated.
---
 src/parse-gram.y | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/parse-gram.y b/src/parse-gram.y
index 0e9cb560..c4b96764 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -780,7 +780,7 @@ translate_code_braceless (char *code, location loc)
 static void
 add_param (param_type type, char *decl, location loc)
 {
-  static char const alphanum[26 + 26 + 1 + 10] =
+  static char const alphanum[26 + 26 + 1 + 10 + 1] =
     "abcdefghijklmnopqrstuvwxyz"
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     "_"
@@ -792,14 +792,14 @@ add_param (param_type type, char *decl, location loc)
     /* Stop on last actual character.  */
     for (p = decl; p[1]; p++)
       if ((p == decl
-           || ! memchr (alphanum, p[-1], sizeof alphanum))
-          && memchr (alphanum, p[0], sizeof alphanum - 10))
+           || ! memchr (alphanum, p[-1], sizeof alphanum - 1))
+          && memchr (alphanum, p[0], sizeof alphanum - 10 - 1))
         name_start = p;
 
     /* Strip the surrounding '{' and '}', and any blanks just inside
        the braces.  */
     --p;
-  while (c_isspace ((unsigned char) *p))
+    while (c_isspace ((unsigned char) *p))
       --p;
     p[1] = '\0';
     ++decl;
-- 
2.17.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]