Skip to content

Commit 105af93

Browse files
committed
Add check for validity of pointer returned by am_onesize_allocate()
1 parent fb41318 commit 105af93

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libs/onesize/onesize.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ void *am_onesize_allocate(struct am_onesize *hnd, int size) {
5757
struct am_slist_item *elem = am_slist_pop_front(&hnd->fl);
5858
AM_ASSERT(elem);
5959

60+
/*
61+
* make sure that onesize freelist bookkeeping state
62+
* was not corrupted by someone
63+
*/
64+
AM_ASSERT((void *)elem >= hnd->pool.ptr);
65+
AM_ASSERT((void *)elem < (void *)((char *)hnd->pool.ptr + hnd->pool.size));
66+
6067
AM_ASSERT(hnd->nfree);
6168
--hnd->nfree;
6269
hnd->minfree = AM_MIN(hnd->minfree, hnd->nfree);

0 commit comments

Comments
 (0)