]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix New_Char_Array with empty arrays
authorRonan Desplanques <desplanques@adacore.com>
Thu, 16 Jan 2025 11:55:37 +0000 (12:55 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 5 Jun 2025 08:18:34 +0000 (10:18 +0200)
commitac936aa57ee0b0a867e80233efefa204b2ae2bc7
treee93580966887b02bcca683bcc047bc7ef4ded589
parentf606f2417b33d88f70b735c1f94f52de5d121ae7
ada: Fix New_Char_Array with empty arrays

This patch fixes an integer underflow issue on calls of the form
New_Char_Array (X) with X'Last < X'First - 2. That integer underflow
caused attempts at allocating impossibly large amount of memory in some
cases.

gcc/ada/ChangeLog:

* libgnat/i-cstrin.adb (Position_Of_Nul): Change specification and
adjust body accordingly.
(New_Char_Array): Fix size of allocation.
(To_Chars_Ptr): Adapt to Position_Of_Nul change.
gcc/ada/libgnat/i-cstrin.adb