GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada unbounded holder no longer dereferences null pointers

GCC's Ada runtime for `Bounded_Indefinite_Holders` now checks for empty holders before dereferencing, preventing null pointer errors.

A null pointer dereference in the Adjust procedure for Ada.Containers.Bounded_Indefinite_Holders.Holder has been fixed. Previously, the procedure would attempt to copy an element’s value without checking if the holder was empty, leading to a crash if the element didn’t exist. The fix introduces a check to ensure the holder is not empty before attempting to access its element, improving runtime stability.

In Details

This fix targets a critical runtime error within libgnat/a-cbinho.adb, specifically in the Adjust procedure for Ada.Containers.Bounded_Indefinite_Holders.Holder. The issue was an unconditional dereference of a potentially null element pointer when a Holder was empty, leading to a null pointer dereference. The patch introduces an explicit check for the holder's emptiness (Is_Empty) before attempting to access or copy the element's value, thus preventing an ICE/runtime crash and improving the robustness of the Ada runtime library for containers.

For Context

Software libraries often include data structures to manage collections of items. In Ada, Bounded_Indefinite_Holders are used to hold items of varying sizes within a predefined memory limit. This commit fixes a bug in the GCC compiler's Ada runtime library related to how it handles these holders. Previously, when a holder was empty (i.e., contained no item), a specific internal procedure (Adjust) would try to access and copy an item that didn't exist, leading to a "null pointer dereference" error, which typically crashes the program. The fix adds a check to ensure the holder actually contains an item before attempting to access it, making programs using these holders more stable and reliable.

Filed Under: adaruntimebugfixnull-pointer