summaryrefslogtreecommitdiffstats
path: root/meta/recipes-sato/puzzles/files/0001-map-Fix-stringop-overflow-warning.patch
blob: 7f46d3ec0eb31b2859dee7942a320450529d8c6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From: Khem Raj <raj.khem@gmail.com>
map: Fix stringop-overflow warning

Fixes

../git/map.c: In function 'new_game_desc':
../git/map.c:1663:23: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 1663 |         ret[retlen++] = ',';
      |         ~~~~~~~~~~~~~~^~~~~
../git/./map.c: In function 'new_game_desc':
../git/./map.c:1663:23: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 1663 |         ret[retlen++] = ',';
      |         ~~~~~~~~~~~~~~^~~~~

Upstream-Status: Submitted [email discussion with upstream]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>

Index: git/map.c
===================================================================
--- git.orig/map.c
+++ git/map.c
@@ -1659,6 +1659,10 @@ static char *new_game_desc(const game_pa
 	    }
 	}
 
+        if (retlen + 10 >= retsize) {
+            retsize = retlen + 256;
+            ret = sresize(ret, retsize, char);
+        }
 	ret[retlen++] = 'a'-1 + run;
 	ret[retlen++] = ',';