Skip to content

Commit ccc21ec

Browse files
committed
Use a sparse file
1 parent 27006ed commit ccc21ec

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ext/tidy/tests/parsing_file_too_large.phpt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ $file = fopen($path, 'w+');
1616

1717
// Write over 4GB
1818
const MIN_FILE_SIZE = 4_294_967_295;
19-
$total_bytes = 0;
20-
$s = str_repeat("a", 10_000);
21-
while ($total_bytes < MIN_FILE_SIZE) {
22-
$bytes_written = fwrite($file, $s);
23-
if ($bytes_written === false) {
24-
echo "Didn't write bytes\n";
25-
}
26-
$total_bytes += $bytes_written;
19+
20+
var_dump(fseek($file, MIN_FILE_SIZE+10));
21+
$s = str_repeat("a", 10);
22+
$bytes_written = fwrite($file, $s);
23+
if ($bytes_written === false) {
24+
echo "Didn't write bytes\n";
2725
}
2826

2927
$tidy = new tidy;
@@ -51,6 +49,7 @@ $path = __DIR__ . '/too_large_test.html';
5149
unlink($path);
5250
?>
5351
--EXPECT--
52+
int(0)
5453
ValueError: Input string is too long
5554
ValueError: Input string is too long
5655
ValueError: Input string is too long

0 commit comments

Comments
 (0)