Commit 55832a08 authored by Edward Catmur's avatar Edward Catmur

Variable-length arrays must have positive bound.

Detected by -fsanitize=vla-bound
parent 065181a1
...@@ -261,7 +261,7 @@ KJ_NORETURN(void unreachable()); ...@@ -261,7 +261,7 @@ KJ_NORETURN(void unreachable());
#define KJ_STACK_ARRAY(type, name, size, minStack, maxStack) \ #define KJ_STACK_ARRAY(type, name, size, minStack, maxStack) \
size_t name##_size = (size); \ size_t name##_size = (size); \
bool name##_isOnStack = name##_size <= (maxStack); \ bool name##_isOnStack = name##_size <= (maxStack); \
type name##_stack[name##_isOnStack ? size : 0]; \ type name##_stack[kj::max(1, name##_isOnStack ? name##_size : 0)]; \
::kj::Array<type> name##_heap = name##_isOnStack ? \ ::kj::Array<type> name##_heap = name##_isOnStack ? \
nullptr : kj::heapArray<type>(name##_size); \ nullptr : kj::heapArray<type>(name##_size); \
::kj::ArrayPtr<type> name = name##_isOnStack ? \ ::kj::ArrayPtr<type> name = name##_isOnStack ? \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment