Pārlūkot izejas kodu

Avoid index out of range

Yasuhiro Matsumoto 5 gadi atpakaļ
vecāks
revīzija
2e1b0c1546
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  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" {