summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-02-16 15:40:40 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2023-02-16 15:43:59 -0500
commitfcf24ae387abebeb6269159a0b8509e9fcdad775 (patch)
tree62a1e286bd87b8ed5eb87ca8c0d0e850ea34d799
parenta749a95840af1d2d17d1f48440231da64c92ce90 (diff)
downloadrockbox-fcf24ae387.tar.gz
rockbox-fcf24ae387.zip
[BUGFIX] chunk_alloc pinned buffer
if there weren't previous chunks new buffer was pinned without being unpinned Change-Id: Ia45bc0eb67673e8df5154447d9116fcd4c147f6b
-rw-r--r--firmware/chunk_alloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/firmware/chunk_alloc.c b/firmware/chunk_alloc.c
index 30959e393d..fd2eb2a772 100644
--- a/firmware/chunk_alloc.c
+++ b/firmware/chunk_alloc.c
@@ -85,6 +85,7 @@ bool chunk_realloc(struct chunk_alloc_header *hdr,
new_chunk = get_chunk_array(ctx, new_handle);
/* ensure all chunks data is zeroed, we depend on it */
memset(new_chunk, 0, CHUNK_ARRSZ(max_chunks));
+ put_chunk_array(ctx, new_chunk);
}
if (hdr->chunk_handle > 0) /* handle existing chunk */
{
@@ -92,10 +93,11 @@ bool chunk_realloc(struct chunk_alloc_header *hdr,
old_chunk = get_chunk_array(ctx, hdr->chunk_handle);
- if (new_chunk != NULL) /* copy any valid old chunks to new */
+ if (new_handle > 0) /* copy any valid old chunks to new */
{
min_chunk = MIN(max_chunks, hdr->current + 1);
logf("%s copying %ld chunks", __func__, min_chunk);
+ new_chunk = get_chunk_array(ctx, new_handle);
memcpy(new_chunk, old_chunk, CHUNK_ARRSZ(min_chunk));
put_chunk_array(ctx, new_chunk);
}