summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-05-30 18:13:18 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-05-30 18:13:18 +0000
commit5127cfad1d997863fa7e8f490c89293b4d0119e7 (patch)
tree556145cff9a1db5ce337ccf3a603c1f1cbd0722e /apps
parent62c88c04de7b4794f124987de68e2e5f41975701 (diff)
downloadrockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.tar.gz
rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.tar.bz2
rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.zip
Fixed incorrect memory allocation bug with tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10023 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/tagcache.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 98beba9b58..866b5c1444 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -1832,6 +1832,10 @@ static bool commit(void)
int i, len, rc;
int tmpfd;
int masterfd;
+#ifdef HAVE_DIRCACHE
+ bool dircache_buffer_stolen = false;
+#endif
+ bool local_allocation = false;
logf("committing tagcache");
@@ -1864,12 +1868,18 @@ static bool commit(void)
}
/* Try to steal every buffer we can :) */
+ if (tempbuf_size == 0)
+ local_allocation = true;
+
#ifdef HAVE_DIRCACHE
if (tempbuf_size == 0)
{
/* Try to steal the dircache buffer. */
tempbuf = dircache_steal_buffer(&tempbuf_size);
tempbuf_size &= ~0x03;
+
+ if (tempbuf_size > 0)
+ dircache_buffer_stolen = true;
}
#endif
@@ -1956,9 +1966,16 @@ static bool commit(void)
logf("tagcache committed");
remove(TAGCACHE_FILE_TEMP);
+ if (local_allocation)
+ {
+ tempbuf = NULL;
+ tempbuf_size = 0;
+ }
+
#ifdef HAVE_DIRCACHE
/* Rebuild the dircache, if we stole the buffer. */
- dircache_build(0);
+ if (dircache_buffer_stolen)
+ dircache_build(0);
#endif
#ifdef HAVE_TC_RAMCACHE