From 2f6246c61d59f52a306ad7d9bef2f969e9580c1f Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Tue, 21 Mar 2023 15:07:58 +0100 Subject: [PATCH] Make sure we don't try to read a character out of bounds --- src/Skia/Avalonia.Skia/TextShaperImpl.cs | 2 +- src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Skia/Avalonia.Skia/TextShaperImpl.cs b/src/Skia/Avalonia.Skia/TextShaperImpl.cs index 153e4f0720..7d7be46c72 100644 --- a/src/Skia/Avalonia.Skia/TextShaperImpl.cs +++ b/src/Skia/Avalonia.Skia/TextShaperImpl.cs @@ -72,7 +72,7 @@ namespace Avalonia.Skia var glyphOffset = GetGlyphOffset(glyphPositions, i, textScale); - if (textSpan[i] == '\t') + if (i < textSpan.Length && textSpan[i] == '\t') { glyphIndex = typeface.GetGlyph(' '); diff --git a/src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs index d42bc3c5cf..36897d3aff 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs @@ -68,7 +68,7 @@ namespace Avalonia.Direct2D1.Media var glyphOffset = GetGlyphOffset(glyphPositions, i, textScale); - if (textSpan[i] == '\t') + if (i < textSpan.Length && textSpan[i] == '\t') { glyphIndex = typeface.GetGlyph(' ');