Skip to content

dbus-mempool: Use flexible or zero-length arrays if possible

Simon McVittie requested to merge smcv/dbus:mempool-flex-array into master

If the elements field has a fixed nonzero size, accessing elements beyond that size is technically undefined behaviour, which is caught by some options of the undefined behaviour sanitizer. Try to use a C99 flexible array, or failing that, a zero-length array (which is a popular non-standard syntax to achieve the same thing).

dbus 1.15.x has C99 as a requirement, but this commit avoids assuming C99 in order to make this change backportable to 1.14.x if it becomes necessary to do so (for example to be able to run tests or fuzzers against 1.14.x, or if compilers' defaults become more strict).


/cc @arichardson @thiago

See also !344 (merged), which is a follow-up to enforce the C99 requirement.

Edited by Simon McVittie

Merge request reports