瀏覽代碼

Merge pull request #10725 from Gillibald/fixes/tabOutOfRange

[Text] Fix potential index out of range exception
Dan Walmsley 2 年之前
父節點
當前提交
a613f77d0b
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/Skia/Avalonia.Skia/TextShaperImpl.cs
  2. 1 1
      src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs

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