1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-26 20:04:51 +01:00

Fix null pointer access in GzipInputStream

This commit is contained in:
Niklas Keller 2017-05-08 09:44:54 +02:00
parent 56ec64c508
commit 59b2454253
2 changed files with 6 additions and 1 deletions

View File

@ -53,4 +53,4 @@ Loop::run(function () use ($stderr, $in, $out) {
$stderr->write('read ' . $bytes . ' byte(s) in ' . round($t, 3) . ' second(s) => ' . round($bytes / 1024 / 1024 / $t, 1) . ' MiB/s' . PHP_EOL);
$stderr->write('peak memory usage of ' . round(memory_get_peak_usage(true) / 1024 / 1024, 1) . ' MiB' . PHP_EOL);
});
});

View File

@ -26,6 +26,11 @@ class GzipInputStream implements InputStream {
$data = yield $this->source->read();
// Needs a double guard, as stream might have been closed while reading
if ($this->resource === null) {
return null;
}
if ($data === null) {
$decompressed = \inflate_add($this->resource, "", \ZLIB_FINISH);