aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2020-04-30 08:55:33 -0400
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:14:09 -0300
commitf5bacfbb585fdbde5678170b9553308a1f6eb935 (patch)
treeab8f8ddafe8b81f63eb40c3c914322ba71c3a088 /gcc
parent61e1942ceccb6a496b21d5e40c4bd026ac9d9a96 (diff)
downloadgcc-f5bacfbb585fdbde5678170b9553308a1f6eb935.zip
gcc-f5bacfbb585fdbde5678170b9553308a1f6eb935.tar.gz
gcc-f5bacfbb585fdbde5678170b9553308a1f6eb935.tar.bz2
[Ada] Style checks on invalid UTF character cause crash
2020-06-19 Justin Squirek <squirek@adacore.com> gcc/ada/ * widechar.adb, widechar.ads (Skip_Wide): Catch validity check failure when skipping over characters, and update comment to reflect Skip_Wide's usage in error printing.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/widechar.adb22
-rw-r--r--gcc/ada/widechar.ads4
2 files changed, 21 insertions, 5 deletions
diff --git a/gcc/ada/widechar.adb b/gcc/ada/widechar.adb
index b7e73a1..3d3ebaf 100644
--- a/gcc/ada/widechar.adb
+++ b/gcc/ada/widechar.adb
@@ -203,7 +203,16 @@ package body Widechar is
-- Start of processing for Skip_Wide
begin
- Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ -- Capture invalid wide characters errors since we are going to discard
+ -- the result anyway. We just want to move past it.
+
+ begin
+ Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ exception
+ when Constraint_Error =>
+ null;
+ end;
+
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
end Skip_Wide;
@@ -235,7 +244,16 @@ package body Widechar is
-- Start of processing for Skip_Wide
begin
- Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ -- Capture invalid wide characters errors since we are going to discard
+ -- the result anyway. We just want to move past it.
+
+ begin
+ Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ exception
+ when Constraint_Error =>
+ null;
+ end;
+
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
end Skip_Wide;
diff --git a/gcc/ada/widechar.ads b/gcc/ada/widechar.ads
index d3d4fc2..f81a19b 100644
--- a/gcc/ada/widechar.ads
+++ b/gcc/ada/widechar.ads
@@ -81,9 +81,7 @@ package Widechar is
-- On entry, S (P) points to an ESC character for a wide character escape
-- sequence or to an upper half character if the encoding method uses the
-- upper bit, or to a left bracket if the brackets encoding method is in
- -- use. On exit, P is bumped past the wide character sequence. No error
- -- checking is done, since this is only used on escape sequences generated
- -- by Set_Wide, which are known to be correct.
+ -- use. On exit, P is bumped past the wide character sequence.
procedure Skip_Wide (S : Source_Buffer_Ptr; P : in out Source_Ptr);
-- Similar to the above procedure, but operates on a source buffer