Browse Source

Make sure we don't try to read a character out of bounds

Benedikt Stebner 2 years ago
parent
commit
2f6246c61d

+ 1 - 1
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(' ');
 

+ 1 - 1
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(' ');