Skip to content

Commit b6da0ff

Browse files
committed
BlueScreen::highlightLine() line may be out of range [Closes #148]
1 parent 37b896f commit b6da0ff

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Tracy/BlueScreen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static function highlightLine($html, $line, $lines = 15)
135135
$source = explode("\n", "\n" . str_replace("\r\n", "\n", $html));
136136
$out = '';
137137
$spans = 1;
138-
$start = $i = max(1, $line - floor($lines * 2 / 3));
138+
$start = $i = max(1, min($line, count($source) - 1) - floor($lines * 2 / 3));
139139
while (--$i >= 1) { // find last highlighted block
140140
if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
141141
if ($m[1] !== '</span>') {

0 commit comments

Comments
 (0)