1
0
Fork 0
forked from len0rd/rockbox

[BUGFIX] chunk_alloc pinned buffer

if there weren't previous chunks new buffer was pinned
without being unpinned

Change-Id: Ia45bc0eb67673e8df5154447d9116fcd4c147f6b
This commit is contained in:
William Wilgus 2023-02-16 15:40:40 -05:00 committed by William Wilgus
parent a749a95840
commit fcf24ae387

View file

@ -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);
}