Package: php-klogger / 1.2.1-2

0002-Fix-test-loop.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Fix test loop
 Avoid infinite loop when getting last line of single-line test logs.
Forwarded: https://github.com/katzgrau/KLogger/pull/83
Author: James Valleroy <jvalleroy@mailbox.org>

--- a/tests/LoggerTest.php
+++ b/tests/LoggerTest.php
@@ -62,6 +62,7 @@
 
     private function getLastLine($filename)
     {
+        $size = filesize($filename);
         $fp = fopen($filename, 'r');
         $pos = -2; // start from second to last char
         $t = ' ';
@@ -70,6 +71,10 @@
             fseek($fp, $pos, SEEK_END);
             $t = fgetc($fp);
             $pos = $pos - 1;
+            if ($size + $pos < -1) {
+                rewind($fp);
+                break;
+            }
         }
 
         $t = fgets($fp);