[PATCH] gcc/config/nios2/nios2.c: Let custom_builtin_name[*] always be zero terminated string

Chen Gang gang.chen.5i5j@gmail.com
Sat Jul 26 04:44:00 GMT 2014


The related strncpy() for custom_builtin_name[*] may set 5 none-zero
characters, which may cause custom_builtin_name[*] is none-zero
terminated.

So add additional '\0' byte for custom_builtin_name[*].

ChangeLog:

	* config/nios2/nios2.c (custom_builtin_name): Let it always be
	zero terminated string.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 gcc/config/nios2/nios2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c
index a4e60c6..e4e005b 100644
--- a/gcc/config/nios2/nios2.c
+++ b/gcc/config/nios2/nios2.c
@@ -2510,7 +2510,7 @@ nios2_expand_fpu_builtin (tree exp, unsigned int code, rtx target)
    total of (3 + 1) * (1 + 3 + 9) == 52 custom builtin functions.
 */
 #define NUM_CUSTOM_BUILTINS ((3 + 1) * (1 + 3 + 9))
-static char custom_builtin_name[NUM_CUSTOM_BUILTINS][5];
+static char custom_builtin_name[NUM_CUSTOM_BUILTINS][6];
 
 static void
 nios2_init_custom_builtins (int start_code)
-- 
1.9.2.459.g68773ac



More information about the Gcc-patches mailing list