summaryrefslogtreecommitdiffstats
path: root/meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch
blob: b572b55d1cff5db68117a5b481b885d6a55d3388 (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
35
36
37
38
39
40
41
42
43
44
45
tree234: Avoid excessive values to malloc

with whole program optimizers like lto, smalloc() is inlined the excessive
constant argument is propagated to malloc() and ultimately triggers the warning.

| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c: In function 'disptree':
| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:46:17: error: argument 1 value '18446744073709551612' exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
|    46 | #define smalloc malloc
|       |                 ^
| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:1631:17: note: in expansion of macro 'smalloc'
|  1631 |     leveldata = smalloc(ht * (width+2));
|       |                 ^~~~~~~
| In file included from tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:29:
| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/recipe-sysroot/usr/include/stdlib.h:539:14: note: in a call to allocation function 'malloc' declared here
|   539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
|       |              ^~~~~~
| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:46:17: error: argument 1 value '18446744073709551600' exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
|    46 | #define smalloc malloc
|       |                 ^
| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:1632:18: note: in expansion of macro 'smalloc'
|  1632 |     ctx.levels = smalloc(ht * sizeof(char *));
|       |                  ^~~~~~~
| In file included from tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:29:
| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/recipe-sysroot/usr/include/stdlib.h:539:14: note: in a call to allocation function 'malloc' declared here
|   539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
|       |              ^~~~~~
| cc1: some warnings being treated as errors

Upstream-Status: Submitted [email discussion with upstream]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

Index: git/tree234.c
===================================================================
--- git.orig/tree234.c
+++ git/tree234.c
@@ -1621,7 +1621,7 @@ void disptree(tree234 *t) {
     dispctx ctx;
     char *leveldata;
     int width = count234(t);
-    int ht = height234(t) * 3 - 2;
+    unsigned int ht = height234(t) * 3 - 2;
     int i;
 
     if (!t->root) {