aboutsummaryrefslogtreecommitdiffstats
path: root/main/make/use-malloc.patch
blob: 8e3284c03ed4e8eea919ec3355ddcc1d216c74e6 (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
Use malloc when construction the command argv instead of stack space.
This fixes overflowing the stack when building webkit on uclibc based
systems.

https://savannah.gnu.org/bugs/index.php?36451

--- ./job.c.orig
+++ ./job.c
@@ -2865,7 +2865,7 @@
 	return new_argv;
       }
 
-    new_line = alloca (shell_len + 1 + sflags_len + 1
+    new_line = xmalloc (shell_len + 1 + sflags_len + 1
                              + (line_len*2) + 1);
     ap = new_line;
     memcpy (ap, shell, shell_len);
@@ -2923,9 +2923,11 @@
 #endif
 	*ap++ = *p;
       }
-    if (ap == new_line + shell_len + sflags_len + 2)
+    if (ap == new_line + shell_len + sflags_len + 2) {
       /* Line was empty.  */
+      free (new_line);
       return 0;
+    }
     *ap = '\0';
 
 #ifdef WINDOWS32
@@ -3065,6 +3067,7 @@
       fatal (NILF, _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"),
             __FILE__, __LINE__);
 #endif
+    free (new_line);
   }
 #endif	/* ! AMIGA */