Skip to content
  • Alex Richardson's avatar
    gsignal.c: drop an optimization that is undefined behaviour · 9769cd0d
    Alex Richardson authored
    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
    9769cd0d