You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: fix safety guards, const correctness, and alignment validation
- Fix potential out-of-bounds memory write in `estack_free_to_marker` under CONTRACT release builds by adding an unconditional guard.
- Fix const-correctness of `estack_print` by removing `const` from the parameter since it temporarily mutates the stack.
- Add compile-time static assertions to validate custom `ESTACK_MIN_ALIGNMENT` and `ESTACK_DEFAULT_HEADER_ALIGNMENT` (power-of-two and minimum size checks).
- Restructure `ESTACK_MIN_ALIGNMENT` preprocessor logic to ensure it behaves correctly when `ESTACK_NO_AUTO_ALIGN` is defined.
- Add warnings in configuration comments regarding potential alignment crashes on strict-alignment systems.
ESTACK_STATIC_ASSERT((ESTACK_MIN_ALIGNMENT& (ESTACK_MIN_ALIGNMENT-1)) ==0, "ESTACK_MIN_ALIGNMENT must be a power of two");
417
422
418
423
/*
419
424
* Configuration: Header Alignment Selection
@@ -446,6 +451,8 @@ ESTACK_STATIC_ASSERT((ESTACK_MAGIC != 0), "ESTACK_MAGIC must be a non-zero value
446
451
# defineESTACK_DEFAULT_HEADER_ALIGNMENT ((size_t)sizeof(uintptr_t)) // Fallback to word alignment
447
452
# endif
448
453
# endif
454
+
ESTACK_STATIC_ASSERT((ESTACK_DEFAULT_HEADER_ALIGNMENT& (ESTACK_DEFAULT_HEADER_ALIGNMENT-1)) ==0, "ESTACK_DEFAULT_HEADER_ALIGNMENT must be a power of two");
455
+
ESTACK_STATIC_ASSERT(ESTACK_DEFAULT_HEADER_ALIGNMENT >= sizeof(uintptr_t), "ESTACK_DEFAULT_HEADER_ALIGNMENT must be greater than or equal to sizeof(uintptr_t)");
0 commit comments