Skip to content

Commit

Permalink
Merge pull request #2 from ralphyon/master
Browse files Browse the repository at this point in the history
Fix block_size_max handling in adjust_request_size
  • Loading branch information
mattconte authored Feb 22, 2018
2 parents 7d6c9a7 + 2b73b8a commit 16b6a96
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tlsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,15 @@ static void* align_ptr(const void* ptr, size_t align)
static size_t adjust_request_size(size_t size, size_t align)
{
size_t adjust = 0;
if (size && size < block_size_max)
if (size)
{
const size_t aligned = align_up(size, align);
adjust = tlsf_max(aligned, block_size_min);

/* aligned sized must not exceed block_size_max or we'll go out of bounds on sl_bitmap */
if (aligned < block_size_max)
{
adjust = tlsf_max(aligned, block_size_min);
}
}
return adjust;
}
Expand Down

0 comments on commit 16b6a96

Please sign in to comment.