Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
diff --git a/apps/playback.c b/apps/playback.c
index bc56d72..2031e99 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -832,6 +832,18 @@ static int shrink_callback(int handle, unsigned hints, void* start, size_t old_s
     /* we should be free to change the buffer now */
     size_t wanted_size = (hints & BUFLIB_SHRINK_SIZE_MASK);
     ssize_t size = (ssize_t)old_size - wanted_size;
+    const size_t minimum = 200<<10;
+
+    /* extrabuflen is the non-variable extra data not used for file buffering */
+    size_t extrabuflen = old_size - filebuflen;
+    /* make sure there is enough space for the extras and file buffering */
+    if (filebuflen <= minimum || size < 0)
+        return BUFLIB_CB_CANNOT_SHRINK;
+    if ((size_t)size < (extrabuflen + minimum))
+    {
+        size = extrabuflen + minimum;
+        wanted_size = old_size - size;
+    }
     switch (hints & BUFLIB_SHRINK_POS_MASK)
     {
         case BUFLIB_SHRINK_POS_BACK: