summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-01-18 18:20:53 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-01-18 19:45:55 +0000
commitaafe2dd2d14e1ce88b5c9c819277ca0bc98af6e5 (patch)
tree6c0f0ec581b24c29d452b492d25c087c335b9b40
parent525eb158643055bd5a652e824ee2db547a323504 (diff)
downloadrockbox-aafe2dd2d1.tar.gz
rockbox-aafe2dd2d1.zip
tagcache: don't allow temp commit buffer to be moved
The temporary buffer used during database commit did not have any buflib callbacks set, which allows it to be moved by buflib at any time. The code is not prepared to deal with this, so things break horribly if anything tries to allocate during the commit. The solution is to pass dummy callbacks to prevent the buffer from being moved. I expect this may create other issues since the commit uses up all available RAM, but at least things won't get silently corrupted anymore. Change-Id: I3183aaee58c94bfbaf4e24424030b8be6e341d22
-rw-r--r--apps/tagcache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index bf23ac74dc..37f443e036 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -326,7 +326,10 @@ static void allocate_tempbuf(void)
if (tempbuf)
tempbuf_size = size;
#else /* !__PCTOOL__ */
- tempbuf_handle = core_alloc_maximum("tc tempbuf", &size, NULL);
+ /* Need to pass dummy ops to prevent the buffer being moved
+ * out from under us, since we yield during the tagcache commit. */
+ static struct buflib_callbacks dummy_ops;
+ tempbuf_handle = core_alloc_maximum("tc tempbuf", &size, &dummy_ops);
if (tempbuf_handle > 0)
{
tempbuf = core_get_data(tempbuf_handle);