瀏覽代碼

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" {