Skip to content

Commit 9f3a3d4

Browse files
authored
pool_i.h: Check available size instead of pointer wrap-around to avoid autological-compare. (#4382)
1 parent 078bfea commit 9f3a3d4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pjlib/include/pj/pool_i.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ PJ_IDEF(void*) pj_pool_alloc_from_block( pj_pool_block *block, pj_size_t alignme
5656
// size = (size + alignment) & ~(alignment -1);
5757
//}
5858
ptr = PJ_POOL_ALIGN_PTR(block->cur, alignment);
59-
if (ptr + size <= block->end &&
60-
/* here we check pointer overflow */
61-
block->cur <= ptr && ptr <= ptr + size) {
59+
if (block->cur <= ptr && /* check pointer overflow */
60+
block->end - ptr >= size) /* check available size */
61+
{
6262
block->cur = ptr + size;
6363
return ptr;
6464
}

0 commit comments

Comments
 (0)