Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 1 | From 3d78d4cffcdc1242892b6c21c26d1c96938c48d1 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 27 Feb 2021 10:02:43 -0800 |
| 4 | Subject: [PATCH] map: Fix stringop-overflow warning |
| 5 | |
| 6 | Fixes |
| 7 | |
| 8 | ../git/map.c: In function 'new_game_desc': |
| 9 | ../git/map.c:1663:23: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] |
| 10 | 1663 | ret[retlen++] = ','; |
| 11 | | ~~~~~~~~~~~~~~^~~~~ |
| 12 | ../git/./map.c: In function 'new_game_desc': |
| 13 | ../git/./map.c:1663:23: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] |
| 14 | 1663 | ret[retlen++] = ','; |
| 15 | | ~~~~~~~~~~~~~~^~~~~ |
| 16 | |
| 17 | Upstream-Status: Pending |
| 18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 19 | --- |
| 20 | map.c | 6 ++++-- |
| 21 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 22 | |
| 23 | diff --git a/map.c b/map.c |
| 24 | index 412305c..fa0c493 100644 |
| 25 | --- a/map.c |
| 26 | +++ b/map.c |
| 27 | @@ -1659,8 +1659,10 @@ static char *new_game_desc(const game_params *params, random_state *rs, |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | - ret[retlen++] = 'a'-1 + run; |
| 32 | - ret[retlen++] = ','; |
| 33 | + if(ret != NULL) { |
| 34 | + ret[retlen++] = 'a'-1 + run; |
| 35 | + ret[retlen++] = ','; |
| 36 | + } |
| 37 | |
| 38 | run = 0; |
| 39 | for (i = 0; i < n; i++) { |
| 40 | -- |
| 41 | 2.30.1 |
| 42 | |