summarylogtreecommitdiffstats
path: root/fix_audio_cache.patch
diff options
context:
space:
mode:
Diffstat (limited to 'fix_audio_cache.patch')
-rw-r--r--fix_audio_cache.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/fix_audio_cache.patch b/fix_audio_cache.patch
new file mode 100644
index 000000000000..f91247d315c1
--- /dev/null
+++ b/fix_audio_cache.patch
@@ -0,0 +1,41 @@
+From 1c6999b33a1b66b46143266ba9f842a32e837484 Mon Sep 17 00:00:00 2001
+From: Myaamori <myaamori1993@gmail.com>
+Date: Thu, 21 May 2020 05:11:15 +0100
+Subject: [PATCH] Fix mutation while iterating corrupting linked list in
+ block_cache.h
+
+---
+ src/block_cache.h | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/block_cache.h b/src/block_cache.h
+index f2ebfa261..4025dac11 100644
+--- a/src/block_cache.h
++++ b/src/block_cache.h
+@@ -91,7 +91,6 @@ class DataBlockCache {
+ size -= (ba.size() - std::count(ba.begin(), ba.end(), nullptr)) * factory.GetBlockSize();
+
+ ba.clear();
+- age.erase(mb.position);
+ }
+
+ public:
+@@ -150,8 +150,16 @@
+ }
+
+ // Remove old entries until we're under the max size
+- for (auto it = age.rbegin(); size > max_size && it != age.rend(); )
+- KillMacroBlock(**it++);
++ auto it = age.end();
++ while (size > max_size) {
++ if (it == age.begin())
++ break;
++ it--;
++ KillMacroBlock(**it);
++ }
++
++ while (it != age.end())
++ it = age.erase(it);
+ }
+
+ /// @brief Obtain a data block from the cache