summaryrefslogtreecommitdiff
path: root/user/mesa/disk_cache-stack-overflow.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/mesa/disk_cache-stack-overflow.patch')
-rw-r--r--user/mesa/disk_cache-stack-overflow.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/user/mesa/disk_cache-stack-overflow.patch b/user/mesa/disk_cache-stack-overflow.patch
new file mode 100644
index 000000000..3fad95259
--- /dev/null
+++ b/user/mesa/disk_cache-stack-overflow.patch
@@ -0,0 +1,42 @@
+The disk cache code tries to allocate a 256 Kbyte buffer on the stack.
+Since musl only gives 80 Kbyte of stack space per thread, this causes a trap.
+
+--- mesa-17.3.1/src/util/disk_cache.c.old 2017-12-21 11:31:22.000000000 -0600
++++ mesa-17.3.1/src/util/disk_cache.c 2017-12-29 01:17:15.625633901 -0600
+@@ -716,7 +716,7 @@
+ deflate_and_write_to_disk(const void *in_data, size_t in_data_size, int dest,
+ const char *filename)
+ {
+- unsigned char out[BUFSIZE];
++ unsigned char *out;
+
+ /* allocate deflate state */
+ z_stream strm;
+@@ -733,6 +733,11 @@
+ /* compress until end of in_data */
+ size_t compressed_size = 0;
+ int flush;
++
++ out = calloc(1, BUFSIZE);
++ if (out == NULL)
++ return 0;
++
+ do {
+ int remaining = in_data_size - BUFSIZE;
+ flush = remaining > 0 ? Z_NO_FLUSH : Z_FINISH;
+@@ -754,6 +759,7 @@
+ ssize_t written = write_all(dest, out, have);
+ if (written == -1) {
+ (void)deflateEnd(&strm);
++ free(out);
+ return 0;
+ }
+ } while (strm.avail_out == 0);
+@@ -768,6 +774,7 @@
+
+ /* clean up and return */
+ (void)deflateEnd(&strm);
++ free(out);
+ return compressed_size;
+ }
+