diff options
author | William Wilgus <wilgus.william@gmail.com> | 2023-02-16 15:40:40 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2023-02-16 15:43:59 -0500 |
commit | fcf24ae387abebeb6269159a0b8509e9fcdad775 (patch) | |
tree | 62a1e286bd87b8ed5eb87ca8c0d0e850ea34d799 | |
parent | a749a95840af1d2d17d1f48440231da64c92ce90 (diff) | |
download | rockbox-fcf24ae387abebeb6269159a0b8509e9fcdad775.tar.gz rockbox-fcf24ae387abebeb6269159a0b8509e9fcdad775.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.c | 4 |
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, | |||
85 | new_chunk = get_chunk_array(ctx, new_handle); | 85 | new_chunk = get_chunk_array(ctx, new_handle); |
86 | /* ensure all chunks data is zeroed, we depend on it */ | 86 | /* ensure all chunks data is zeroed, we depend on it */ |
87 | memset(new_chunk, 0, CHUNK_ARRSZ(max_chunks)); | 87 | memset(new_chunk, 0, CHUNK_ARRSZ(max_chunks)); |
88 | put_chunk_array(ctx, new_chunk); | ||
88 | } | 89 | } |
89 | if (hdr->chunk_handle > 0) /* handle existing chunk */ | 90 | if (hdr->chunk_handle > 0) /* handle existing chunk */ |
90 | { | 91 | { |
@@ -92,10 +93,11 @@ bool chunk_realloc(struct chunk_alloc_header *hdr, | |||
92 | 93 | ||
93 | old_chunk = get_chunk_array(ctx, hdr->chunk_handle); | 94 | old_chunk = get_chunk_array(ctx, hdr->chunk_handle); |
94 | 95 | ||
95 | if (new_chunk != NULL) /* copy any valid old chunks to new */ | 96 | if (new_handle > 0) /* copy any valid old chunks to new */ |
96 | { | 97 | { |
97 | min_chunk = MIN(max_chunks, hdr->current + 1); | 98 | min_chunk = MIN(max_chunks, hdr->current + 1); |
98 | logf("%s copying %ld chunks", __func__, min_chunk); | 99 | logf("%s copying %ld chunks", __func__, min_chunk); |
100 | new_chunk = get_chunk_array(ctx, new_handle); | ||
99 | memcpy(new_chunk, old_chunk, CHUNK_ARRSZ(min_chunk)); | 101 | memcpy(new_chunk, old_chunk, CHUNK_ARRSZ(min_chunk)); |
100 | put_chunk_array(ctx, new_chunk); | 102 | put_chunk_array(ctx, new_chunk); |
101 | } | 103 | } |