mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 12:25:48 +01:00
9769cd0d24
Comparing reallocated pointers is UB, but this happens to work for now on most compilers. However, for CHERI systems if g_bsearch_array_insert() reallocs in-place then the new `hlbsa` pointer may have larger bounds than `o` and using the old pointer with the smaller bounds can result in a bounds error. I don't think this code is performance critical, so removing the optimization and inserting unconditionally should be fine. Currently, this realloc() UB rarely causes issues, but newer versions of GCC with _FORTIFY_SOURCE=3 might also be able to observe the valid memory range (assuming sufficient inlining). See https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level