ソースを参照

Avoid index out of range

Yasuhiro Matsumoto 5 年 前
コミット
2e1b0c1546
1 ファイル変更2 行追加2 行削除
  1. 2 2
      colorable_windows.go

+ 2 - 2
colorable_windows.go

@@ -719,7 +719,7 @@ loop:
 									n256setup()
 								}
 								attr &= backgroundMask
-								attr |= n256foreAttr[n256]
+								attr |= n256foreAttr[n256%len(n256foreAttr)]
 								i += 2
 							}
 						} else if len(token) == 5 && token[i+1] == "2" {
@@ -761,7 +761,7 @@ loop:
 									n256setup()
 								}
 								attr &= foregroundMask
-								attr |= n256backAttr[n256]
+								attr |= n256backAttr[n256%len(n256backAttr)]
 								i += 2
 							}
 						} else if len(token) == 5 && token[i+1] == "2" {