Skip to content

fix null pointer dereference on allocation failure in aligned allocators - #4820

Open
aouxwoux wants to merge 1 commit into
bulletphysics:masterfrom
aouxwoux:fix-allocator-null-dereference
Open

aouxwoux wants to merge 1 commit into
bulletphysics:masterfrom
aouxwoux:fix-allocator-null-dereference

Conversation

@aouxwoux

Copy link
Copy Markdown

fixes #4819

what changed

  • in btAllocDefault and btAlignedAllocDefault, guard memset so that null pointers returned upon allocation failure are not dereferenced.
  • in debug allocators (btAlignedAllocInternal and b3AlignedAllocInternal), guard allocator statistics and debug sentinel writes (*ptr = 12) when the underlying allocation returns null.
  • in b3AlignedAllocInternal, avoid incrementing allocation count when allocation returns null.
  • add regression unit tests in test/collision/main.cpp covering custom allocator failure, custom aligned allocator failure, zero-initialization, alignment invariants, and null pointer free handling.

checks

  • ctest passed cleanly locally (all test suites including Test_Collision_PASS).
  • verified under gcc with -fsanitize=address,undefined on both debug and non-debug allocator paths with zero errors or leaks.

@aouxwoux aouxwoux closed this Nov 24, 2026
@aouxwoux aouxwoux reopened this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Null pointer passed to memset after allocation failure in Bullet default allocators

1 participant