diff --git a/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb b/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb index 5f71b3f7..06f61adb 100644 --- a/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb +++ b/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb @@ -576,7 +576,9 @@ package body VSS.Implementation.Text_Handlers.UTF8.Dynamic is return; end if; - Unchecked_Forward (Self.Pointer.Storage, After); + if To.Index <= Self.Length then + Unchecked_Forward (Self.Pointer.Storage, After); + end if; Size := After.UTF8_Offset - From.UTF8_Offset; Length := After.Index - From.Index; diff --git a/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb b/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb index 58f6664e..1e4a5e83 100644 --- a/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb +++ b/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb @@ -515,7 +515,9 @@ package body VSS.Implementation.Text_Handlers.UTF8.Static is return; end if; - Unchecked_Forward (Self.Storage, After); + if To.Index <= Self.Length then + Unchecked_Forward (Self.Storage, After); + end if; Size := After.UTF8_Offset - From.UTF8_Offset; Length := After.Index - From.Index;