aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2024-07-03 15:23:34 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-08-01 17:14:38 +0200
commit88fc730efdd31cc4bf13932ff3cc5b097a5eb23c (patch)
tree242f798c95a10a0185b4284faa1098ddac9ce167
parent8739098f8d2b7de85516be4272e70f1898ba1271 (diff)
downloadgcc-88fc730efdd31cc4bf13932ff3cc5b097a5eb23c.zip
gcc-88fc730efdd31cc4bf13932ff3cc5b097a5eb23c.tar.gz
gcc-88fc730efdd31cc4bf13932ff3cc5b097a5eb23c.tar.bz2
ada: Fix computation of new size when reallocating unbounded string
The procedure Realloc_For_Chunk which is used to reallocate an unbounded string when needed may lead in theory to an overflow, due to the use of variable S_Length denoting the current allocated length instead of Source.Last denoting the current string length. Now fixed. This has no effect in practice since the only targets that use this version of Ada.Strings.Unbounded do not have enough memory to make it possible to have an overflow here. gcc/ada/ * libgnat/a-strunb.adb (Realloc_For_Chunk): Fix computation of new size.
-rw-r--r--gcc/ada/libgnat/a-strunb.adb2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/ada/libgnat/a-strunb.adb b/gcc/ada/libgnat/a-strunb.adb
index 219abad..c3d4c7127 100644
--- a/gcc/ada/libgnat/a-strunb.adb
+++ b/gcc/ada/libgnat/a-strunb.adb
@@ -824,7 +824,7 @@ package body Ada.Strings.Unbounded is
declare
New_Size : constant Positive :=
Saturated_Sum
- (Sum (S_Length, Chunk_Size), S_Length / Growth_Factor);
+ (Sum (Source.Last, Chunk_Size), S_Length / Growth_Factor);
New_Rounded_Up_Size : constant Positive :=
Saturated_Mul